code: def run_summaries(
      metrics: Sequence[PyMetricType],
      session: Optional[tf.compat.v1.Session] = None,
  ):
      """Execute summary ops for py_metrics.
  
      Args:
        metrics: A list of py_metric.Base objects.
        session: A TensorFlow session-like object. If it is not provided, it will
          use the current TensorFlow session context manager.
  
      Raises:
        RuntimeError: If .tf_summaries() was not previously called on any of the
          `metrics`.
        AttributeError: If session is not provided and there is no default session
          provided by a context manager.
      """
      if session is None:
          default_session = tf.compat.v1.get_default_session()
          if default_session is None:
              raise AttributeError(
                  "No TensorFlow session-like object was provided, and none "
                  "could be retrieved using 'tf.get_default_session()'."
              )
          session = default_session
  
      for metric in metrics:
          if metric.summary_op is None:
              raise RuntimeError(
                  "metric.tf_summaries() must be called on py_metric "
                  "{} before attempting to run "
                  "summaries.".format(metric.name)
              )
      summary_ops = [metric.summary_op for metric in metrics]
      feed_dict = dict(
          (metric.summary_placeholder, metric.result())
          for metric in metrics
      )
      session.run(summary_ops, feed_dict=feed_dict)
  
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 1 for calling a global function with example usage: run_summaries(metrics, session) without return types