code: def run(
      length, width, height, fps, level, record, demo, demofiles, video
  ):
      """Spins up an environment and runs the random agent."""
      config = {
          "fps": str(fps),
          "width": str(width),
          "height": str(height),
      }
      if record:
          config["record"] = record
      if demo:
          config["demo"] = demo
      if demofiles:
          config["demofiles"] = demofiles
      if video:
          config["video"] = video
      env = deepmind_lab.Lab(level, ["RGB_INTERLEAVED"], config=config)
  
      env.reset()
  
      # Starts the random spring agent. As a simpler alternative, we could also
      # use DiscretizedRandomAgent().
      agent = SpringAgent(env.action_spec())
  
      reward = 0
  
      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["RGB_INTERLEAVED"])
          reward = env.step(action, num_steps=1)
  
      print(
          "Finished after %i steps. Total reward received is %f"
          % (length, agent.rewards)
      )
  
file_path: lab/python/random_agent.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import random
  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, record, demo, demofiles, video) without return types