class_docstr: An agent implementing the EXP3 bandit algorithm.
  
  Implementation based on
  
  "Bandit Algorithms"
    Lattimore and Szepesvari, 2019
    https://tor-lattimore.com/downloads/book/book.pdf
class_docstr_tok: ["An","agent","implementing","the","EXP3","bandit","algorithm",".","Implementation","based","on","''","Bandit","Algorithms","''","Lattimore","and","Szepesvari",",","2019","https",":","\/\/tor-lattimore.com\/downloads\/book\/book.pdf"]
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: Unused.
  
  Returns:
    A `LossInfo` containing the loss *before* the training step is taken.
      Note that the loss does not depend on policy state and comes directly
      from the experience (and is therefore not differentiable).
  
      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",":","Unused",".","Returns",":","A","`","LossInfo","`","containing","the","loss","*","before","*","the","training","step","is","taken",".","Note","that","the","loss","does","not","depend","on","policy","state","and","comes","directly","from","the","experience","(","and","is","therefore","not","differentiable",")",".","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: Unused.
  
      Returns:
        A `LossInfo` containing the loss *before* the training step is taken.
          Note that the loss does not depend on policy state and comes directly
          from the experience (and is therefore not differentiable).
  
          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.
      """
      del weights  # unused
      experience = self._as_trajectory(experience)
      reward = experience.reward
      log_prob = policy_step.get_log_probability(experience.policy_info)
      action = experience.action
      update_value = exp3_update_value(reward, log_prob)
      weight_update = selective_sum(
          values=update_value,
          partitions=action,
          num_partitions=self.num_actions,
      )
      tf.compat.v1.assign_add(self._weights, weight_update)
  
      batch_size = tf.cast(tf.size(reward), dtype=tf.int64)
      self._train_step_counter.assign_add(batch_size)
  
      return tf_agent.LossInfo(
          loss=-tf.reduce_sum(experience.reward), extra=()
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Text
  import gin
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.bandits.policies import categorical_policy
  from tf_agents.policies import utils
  from tf_agents.trajectories import policy_step
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 7 for calling the Exp3Agent obj's underlying member method code with example usage: obj._train(experience, weights) and returns: tf_agent