code: def testAverageOneEpisodeWithReset(
      self, metric_class, expected_result
  ):
      metric = metric_class()
  
      metric(trajectory.first((), (), (), 0.0, 1.0))
      metric(trajectory.mid((), (), (), 1.0, 1.0))
      metric(trajectory.mid((), (), (), 2.0, 1.0))
      # The episode is reset.
      #
      # This could happen when using the dynamic_episode_driver with
      # parallel_py_environment. When the parallel episodes are of different
      # lengths and num_episodes is reached, some episodes would be left in "MID".
      # When the driver runs again, all environments are reset at the beginning
      # of the tf.while_loop and the unfinished episodes would get "FIRST" without
      # seeing "LAST".
      metric(trajectory.first((), (), (), 3.0, 1.0))
      metric(trajectory.last((), (), (), 4.0, 1.0))
      self.assertEqual(expected_result, metric.result())
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tf_agents.metrics import py_metrics
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 5 for calling the PyMetricsTest obj's underlying member method code with example usage: obj.testAverageOneEpisodeWithReset(metric_class, expected_result) without return types