class_docstr: An agent implementing the LinUCB algorithm on top of a neural network.
docstr: Updates the policy based on the data in `experience`.
  
  Note that `experience` should only contain data points that this agent has
  not previously seen. If `experience` comes from a replay buffer, this buffer
  should be cleared between each call to `train`.
  
  Args:
    experience: A batch of experience data in the form of a `Trajectory`.
    weights: (optional) sample weights.
  
  Returns:
      A `LossInfo` containing the loss *before* the training step is taken.
      In most cases, if `weights` is provided, the entries of this tuple will
      have been calculated with the weights.  Note that each Agent chooses
      its own method of applying weights.
docstr_tok: ["Updates","the","policy","based","on","the","data","in","`","experience","`",".","Note","that","`","experience","`","should","only","contain","data","points","that","this","agent","has","not","previously","seen",".","If","`","experience","`","comes","from","a","replay","buffer",",","this","buffer","should","be","cleared","between","each","call","to","`","train","`",".","Args",":","experience",":","A","batch","of","experience","data","in","the","form","of","a","`","Trajectory","`",".","weights",":","(","optional",")","sample","weights",".","Returns",":","A","`","LossInfo","`","containing","the","loss","*","before","*","the","training","step","is","taken",".","In","most","cases",",","if","`","weights","`","is","provided",",","the","entries","of","this","tuple","will","have","been","calculated","with","the","weights",".","Note","that","each","Agent","chooses","its","own","method","of","applying","weights","."]
code: def _train(self, experience, weights=None):
      """Updates the policy based on the data in `experience`.
  
      Note that `experience` should only contain data points that this agent has
      not previously seen. If `experience` comes from a replay buffer, this buffer
      should be cleared between each call to `train`.
  
      Args:
        experience: A batch of experience data in the form of a `Trajectory`.
        weights: (optional) sample weights.
  
      Returns:
          A `LossInfo` containing the loss *before* the training step is taken.
          In most cases, if `weights` is provided, the entries of this tuple will
          have been calculated with the weights.  Note that each Agent chooses
          its own method of applying weights.
      """
      experience = self._as_trajectory(experience)
  
      (
          observation,
          action,
          reward,
      ) = bandit_utils.process_experience_for_neural_agents(
          experience,
          self._accepts_per_arm_features,
          self.training_data_spec,
      )
      if self._observation_and_action_constraint_splitter is not None:
          (
              observation,
              _,
          ) = self._observation_and_action_constraint_splitter(
              observation
          )
      reward = tf.cast(reward, self._dtype)
  
      if tf.distribute.has_strategy():
          if self._distributed_train_encoding_network:
              loss_info = self.compute_loss_using_reward_layer(
                  observation, action, reward, weights, training=True
              )
          else:
              loss_info = self.compute_loss_using_linucb_distributed(
                  observation, action, reward, weights, training=True
              )
          return loss_info
  
      tf.compat.v1.assign(
          self.actions_from_reward_layer,
          tf.less(
              self._train_step_counter,
              self._encoding_network_num_train_steps,
          ),
      )
  
      def use_actions_from_reward_layer():
          return self.compute_loss_using_reward_layer(
              observation, action, reward, weights, training=True
          )
  
      def no_actions_from_reward_layer():
          return self.compute_loss_using_linucb(
              observation, action, reward, weights, training=True
          )
  
      loss_info = tf.cond(
          self.actions_from_reward_layer,
          use_actions_from_reward_layer,
          no_actions_from_reward_layer,
      )
      return loss_info
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Sequence, Text
  import gin
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.bandits.agents import linear_bandit_agent
  from tf_agents.bandits.agents import utils
  from tf_agents.bandits.policies import neural_linucb_policy
  from tf_agents.bandits.specs import utils
  from tf_agents.policies import utils
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import eager_utils
label_desc: Use image node_id 16 for calling the NeuralLinUCBAgent obj's underlying member method code with example usage: obj._train(experience, weights) and returns: loss_info, loss_info, self, self