code: def testMetricIsComputedCorrectly(self):
      def reward_fn(*unused_args):
          reward = np.random.uniform()
          reward_fn.total_reward += reward
          return reward
  
      reward_fn.total_reward = 0
  
      action_spec = array_spec.BoundedArraySpec((1,), np.int32, -10, 10)
      observation_spec = array_spec.BoundedArraySpec(
          (1,), np.int32, -10, 10
      )
      env = random_py_environment.RandomPyEnvironment(
          observation_spec, action_spec, reward_fn=reward_fn
      )
      policy = random_py_policy.RandomPyPolicy(
          time_step_spec=None, action_spec=action_spec
      )
  
      average_return = py_metrics.AverageReturnMetric()
  
      num_episodes = 10
      results = metric_utils.compute(
          [average_return], env, policy, num_episodes
      )
      self.assertAlmostEqual(
          reward_fn.total_reward / num_episodes,
          results[average_return.name],
          places=5,
      )
  
file_path: agents/tf_agents/eval/metric_utils_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow
  from tf_agents.environments import random_py_environment
  from tf_agents.eval import metric_utils
  from tf_agents.metrics import py_metrics
  from tf_agents.policies import random_py_policy
  from tf_agents.specs import array_spec
label_desc: Use image node_id 1 for calling the MetricUtilsTest obj's underlying member method code with example usage: obj.testMetricIsComputedCorrectly() and returns: reward