docstr: Check updates when behaving like eps-greedy and using masked actions.
docstr_tok: ["Check","updates","when","behaving","like","eps-greedy","and","using","masked","actions","."]
code: def testNeuralLinUCBUpdateNumTrainSteps10MaskedActions(
      self, batch_size=1, context_dim=10
  ):
      """Check updates when behaving like eps-greedy and using masked actions."""
  
      # Construct a `Trajectory` for the given action, observation, reward.
      num_actions = 5
      (
          initial_step,
          final_step,
      ) = _get_initial_and_final_steps_with_action_mask(
          batch_size, context_dim, num_actions
      )
      action = np.random.randint(
          num_actions, size=batch_size, dtype=np.int32
      )
      action_step = _get_action_step(action)
      experience = _get_experience(
          initial_step, action_step, final_step
      )
  
      # Construct an agent and perform the update.
      observation_spec = (
          tensor_spec.TensorSpec([context_dim], tf.float32),
          tensor_spec.TensorSpec([num_actions], tf.int32),
      )
      time_step_spec = time_step.time_step_spec(observation_spec)
      action_spec = tensor_spec.BoundedTensorSpec(
          dtype=tf.int32, shape=(), minimum=0, maximum=num_actions - 1
      )
      encoder = DummyNet(observation_spec[0])
      encoding_dim = 10
      agent = neural_linucb_agent.NeuralLinUCBAgent(
          time_step_spec=time_step_spec,
          action_spec=action_spec,
          encoding_network=encoder,
          encoding_network_num_train_steps=10,
          encoding_dim=encoding_dim,
          optimizer=tf.compat.v1.train.AdamOptimizer(
              learning_rate=0.001
          ),
          observation_and_action_constraint_splitter=lambda x: (
              x[0],
              x[1],
          ),
      )
  
      loss_info, _ = agent.train(experience)
      self.evaluate(agent.initialize())
      self.evaluate(tf.compat.v1.global_variables_initializer())
      loss_value = self.evaluate(loss_info)
      self.assertGreater(loss_value, 0.0)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.bandits.agents import neural_linucb_agent
  from tf_agents.bandits.agents import utils
  from tf_agents.bandits.drivers import driver_utils
  from tf_agents.bandits.networks import global_and_arm_feature_network
  from tf_agents.bandits.specs import utils
  from tf_agents.networks import network
  from tf_agents.policies import utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.utils import common
label_desc: Use image node_id 7 for calling the NeuralLinUCBAgentTest obj's underlying member method code with example usage: obj.testNeuralLinUCBUpdateNumTrainSteps10MaskedActions(batch_size, context_dim) without return types