class_docstr: Wraps a python metric as a TF metric.
class_docstr_tok: ["Wraps","a","python","metric","as","a","TF","metric","."]
docstr: Update the value of the metric using trajectory.
  
  The trajectory can be either batched or un-batched depending on
  the expected inputs for the py_metric being wrapped.
  
  Args:
    trajectory: A tf_agents.trajectory.Trajectory.
  
  Returns:
    The arguments, for easy chaining.
docstr_tok: ["Update","the","value","of","the","metric","using","trajectory",".","The","trajectory","can","be","either","batched","or","un-batched","depending","on","the","expected","inputs","for","the","py_metric","being","wrapped",".","Args",":","trajectory",":","A","tf_agents.trajectory.Trajectory",".","Returns",":","The","arguments",",","for","easy","chaining","."]
code: def call(self, trajectory):
      """Update the value of the metric using trajectory.
  
      The trajectory can be either batched or un-batched depending on
      the expected inputs for the py_metric being wrapped.
  
      Args:
        trajectory: A tf_agents.trajectory.Trajectory.
  
      Returns:
        The arguments, for easy chaining.
      """
  
      def _call(*flattened_trajectories):
          with _check_not_called_concurrently(self._lock):
              flat_sequence = [
                  x.numpy() for x in flattened_trajectories
              ]
              packed_trajectories = tf.nest.pack_sequence_as(
                  structure=(trajectory), flat_sequence=flat_sequence
              )
              return self._py_metric(packed_trajectories)
  
      flattened_trajectories = tf.nest.flatten(trajectory)
      metric_op = tf.py_function(
          _call, flattened_trajectories, [], name="metric_call_py_func"
      )
  
      with tf.control_dependencies([metric_op]):
          return tf.nest.map_structure(tf.identity, trajectory)
  
file_path: agents/tf_agents/metrics/tf_py_metric.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import threading
  import tensorflow
  from tf_agents.metrics import tf_metric
label_desc: Use image node_id 2 for calling the TFPyMetric obj's underlying member method code with example usage: obj.call(trajectory) and returns: tf, self