class_docstr: Short benchmarks (~110 steps) for DQN CartPole environment.
class_docstr_tok: ["Short","benchmarks","(","~110","steps",")","for","DQN","CartPole","environment","."]
docstr: Run function provided and report results per `tf.test.Benchmark`.
  
  Args:
    train_step: Function to execute on each step.
    strategy: Strategy to use, None is a valid value.
    batch_size: Total batch_size.
    train_steps: Number of steps to run.
    log_steps: How often to log step statistics, e.g. step time.
    iterator: Iterator to dataset to pass to train_step.
  
  Returns:
    `TimeHistory` object with statistics about the throughput perforamnce.
docstr_tok: ["Run","function","provided","and","report","results","per","`","tf.test.Benchmark","`",".","Args",":","train_step",":","Function","to","execute","on","each","step",".","strategy",":","Strategy","to","use",",","None","is","a","valid","value",".","batch_size",":","Total","batch_size",".","train_steps",":","Number","of","steps","to","run",".","log_steps",":","How","often","to","log","step","statistics",",","e.g",".","step","time",".","iterator",":","Iterator","to","dataset","to","pass","to","train_step",".","Returns",":","`","TimeHistory","`","object","with","statistics","about","the","throughput","perforamnce","."]
code: def run_and_report(
      self,
      train_step,
      strategy,
      batch_size,
      train_steps=110,
      log_steps=10,
      iterator=None,
  ):
      """Run function provided and report results per `tf.test.Benchmark`.
  
      Args:
        train_step: Function to execute on each step.
        strategy: Strategy to use, None is a valid value.
        batch_size: Total batch_size.
        train_steps: Number of steps to run.
        log_steps: How often to log step statistics, e.g. step time.
        iterator: Iterator to dataset to pass to train_step.
  
      Returns:
        `TimeHistory` object with statistics about the throughput perforamnce.
      """
      history = utils.run_test(
          train_step,
          train_steps,
          strategy,
          batch_size=batch_size,
          log_steps=log_steps,
          iterator=iterator,
      )
      print("Avg step time:{}".format(history.get_average_step_time()))
      print(
          "Avg exp/sec:{}".format(
              history.get_average_examples_per_second()
          )
      )
      metrics = []
      metrics.append(
          {
              "name": "exp_per_second",
              "value": history.get_average_examples_per_second(),
          }
      )
      metrics.append(
          {
              "name": "steps_per_second",
              "value": 1 / history.get_average_step_time(),
          }
      )
      metrics.append(
          {
              "name": "step_time",
              "value": history.get_average_step_time(),
          }
      )
      self.report_benchmark(
          iters=-1,
          wall_time=history.get_average_step_time(),
          metrics=metrics,
      )
      return history
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import unittest
  import numpy
  from six.moves import range
  import tensorflow
  from tf_agents.agents.dqn import dqn_agent
  from tf_agents.benchmark import distribution_strategy_utils
  from tf_agents.benchmark import utils
  from tf_agents.drivers import dynamic_step_driver
  from tf_agents.environments import random_py_environment
  from tf_agents.environments import tf_py_environment
  from tf_agents.networks import q_network
  from tf_agents.policies import random_tf_policy
  from tf_agents.replay_buffers import tf_uniform_replay_buffer
  from tf_agents.specs import array_spec
  from tf_agents.utils import common
  from tensorflow.python import tf2
label_desc: Use image node_id 2 for calling the DqnCartPoleAgentBenchmark obj's underlying member method code with example usage: obj.run_and_report(train_step, strategy, batch_size, train_steps, log_steps, iterator) and returns: history