code: def run(length, width, height, fps, level, observation_spec):
      """Spins up an environment and runs the random agent."""
      env = deepmind_lab.Lab(
          level,
          [observation_spec],
          config={
              "fps": str(fps),
              "width": str(width),
              "height": str(height),
          },
      )
  
      env.reset()
  
      agent = DiscretizedRandomAgent()
  
      reward = 0
  
      t0 = time.time()
  
      for _ in six.moves.range(length):
          if not env.is_running():
              print("Environment stopped early")
              env.reset()
              agent.reset()
          obs = env.observations()
          action = agent.step(reward, obs[observation_spec])
          reward = env.step(action, num_steps=1)
  
      t1 = time.time()
      duration = t1 - t0
  
      print(
          "resolution: %i x %i, spec: %s, steps: %i, duration: %.1f, fps: %.1f"
          % (
              width,
              height,
              observation_spec,
              length,
              duration,
              length / duration,
          )
      )
  
file_path: lab/python/tests/benchmark.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import random
  import time
  import numpy
  import six
  import deepmind_lab
label_desc: Use image node_id 2 for calling a global function with example usage: run(length, width, height, fps, level, observation_spec) without return types