class_docstr: Difference between the estimated reward of the chosen and the best action.
  
  This metric measures how 'safely' the agent explores: it calculates the
  difference between what the agent thinks it would have gotten had it chosen
  the best looking action, vs the action it actually took. This metric is not
  equivalent to the regret, because the regret is calculated as a distance from
  optimality, while here everything calculated is based on the policy's
  'belief'.
class_docstr_tok: ["Difference","between","the","estimated","reward","of","the","chosen","and","the","best","action",".","This","metric","measures","how","'safely","'","the","agent","explores",":","it","calculates","the","difference","between","what","the","agent","thinks","it","would","have","gotten","had","it","chosen","the","best","looking","action",",","vs","the","action","it","actually","took",".","This","metric","is","not","equivalent","to","the","regret",",","because","the","regret","is","calculated","as","a","distance","from","optimality",",","while","here","everything","calculated","is","based","on","the","policy's","'belief","'","."]
docstr: Update the metric value.
  
  Args:
    trajectory: A tf_agents.trajectory.Trajectory
  
  Returns:
    The arguments, for easy chaining.
docstr_tok: ["Update","the","metric","value",".","Args",":","trajectory",":","A","tf_agents.trajectory.Trajectory","Returns",":","The","arguments",",","for","easy","chaining","."]
code: def call(self, trajectory):
      """Update the metric value.
  
      Args:
        trajectory: A tf_agents.trajectory.Trajectory
  
      Returns:
        The arguments, for easy chaining.
      """
      all_estimated_rewards = self._estimated_reward_fn(
          trajectory.observation
      )
      max_estimated_rewards = tf.reduce_max(
          all_estimated_rewards, axis=-1
      )
      estimated_action_rewards = tf.gather(
          all_estimated_rewards, trajectory.action, batch_dims=1
      )
      self.safe_explore.assign(
          tf.reduce_mean(
              max_estimated_rewards - estimated_action_rewards
          )
      )
      return trajectory
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Callable, Optional, Text
  import gin
  import tensorflow
  from tf_agents.bandits.policies import constraints
  from tf_agents.bandits.specs import utils
  from tf_agents.metrics import tf_metric
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 2 for calling the DistanceFromGreedyMetric obj's underlying member method code with example usage: obj.call(trajectory) and returns: trajectory