class_docstr: Defines the interface for metrics.
docstr: Build TF summary op and placeholder for this metric.
  
  To execute the op, call py_metric.run_summaries.
  
  Args:
    train_step: Step counter for training iterations. If None, no metric is
      generated against the global step.
    step_metrics: Step values to plot as X axis in addition to global_step.
  
  Returns:
    The summary op.
  
  Raises:
    RuntimeError: If this method has already been called (it can only be
      called once).
    ValueError: If any item in step_metrics is not of type PyMetric or
      tf_metric.TFStepMetric.
docstr_tok: ["Build","TF","summary","op","and","placeholder","for","this","metric",".","To","execute","the","op",",","call","py_metric.run_summaries",".","Args",":","train_step",":","Step","counter","for","training","iterations",".","If","None",",","no","metric","is","generated","against","the","global","step",".","step_metrics",":","Step","values","to","plot","as","X","axis","in","addition","to","global_step",".","Returns",":","The","summary","op",".","Raises",":","RuntimeError",":","If","this","method","has","already","been","called","(","it","can","only","be","called","once",")",".","ValueError",":","If","any","item","in","step_metrics","is","not","of","type","PyMetric","or","tf_metric.TFStepMetric","."]
code: def tf_summaries(
      self,
      train_step: types.Int = None,
      step_metrics: Sequence[MetricType] = (),
  ) -> tf.Operation:
      """Build TF summary op and placeholder for this metric.
  
      To execute the op, call py_metric.run_summaries.
  
      Args:
        train_step: Step counter for training iterations. If None, no metric is
          generated against the global step.
        step_metrics: Step values to plot as X axis in addition to global_step.
  
      Returns:
        The summary op.
  
      Raises:
        RuntimeError: If this method has already been called (it can only be
          called once).
        ValueError: If any item in step_metrics is not of type PyMetric or
          tf_metric.TFStepMetric.
      """
      if self.summary_op is not None:
          raise RuntimeError(
              "metric.tf_summaries() can only be called once."
          )
  
      tag = common.join_scope(self.prefix, self.name)
      summaries = []
      summaries.append(
          tf.compat.v2.summary.scalar(
              name=tag, data=self.summary_placeholder, step=train_step
          )
      )
      prefix = self.prefix
      if prefix:
          prefix += "_"
      for step_metric in step_metrics:
          # Skip plotting the metrics against itself.
          if self.name == step_metric.name:
              continue
          step_tag = "{}vs_{}/{}".format(
              prefix, step_metric.name, self.name
          )
          if isinstance(step_metric, PyMetric):
              step_tensor = step_metric.summary_placeholder
          elif isinstance(step_metric, tf_metric.TFStepMetric):
              step_tensor = step_metric.result()
          else:
              raise ValueError(
                  "step_metric is not PyMetric or TFStepMetric: {}".format(
                      step_metric
                  )
              )
          summaries.append(
              tf.compat.v2.summary.scalar(
                  name=step_tag,
                  data=self.summary_placeholder,
                  step=step_tensor,
              )
          )
  
      self._summary_op = tf.group(*summaries)
      return self._summary_op
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  from typing import Any, Optional, Sequence, Text, Union
  from absl import logging
  import numpy
  import six
  import tensorflow
  from tf_agents.metrics import tf_metric
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 6 for calling the PyMetric obj's underlying member method code with example usage: obj.tf_summaries(train_step, step_metrics) and returns: self