code: def main(_):
      # A thunk that builds a new environment.
      # Substitute your environment here!
      build_env = catch.Catch
  
      # Construct the agent. We need a sample environment for its spec.
      env_for_spec = build_env()
      num_actions = env_for_spec.action_spec().num_values
      agent = agent_lib.Agent(
          num_actions,
          env_for_spec.observation_spec(),
          haiku_nets.CatchNet,
      )
  
      # Construct the optimizer.
      max_updates = MAX_ENV_FRAMES / FRAMES_PER_ITER
      opt = optax.rmsprop(5e-3, decay=0.99, eps=1e-7)
  
      # Construct the learner.
      learner = learner_lib.Learner(
          agent,
          jax.random.PRNGKey(428),
          opt,
          BATCH_SIZE,
          DISCOUNT_FACTOR,
          FRAMES_PER_ITER,
          max_abs_reward=1.0,
          logger=util.AbslLogger(),  # Provide your own logger here.
      )
  
      # Construct the actors on different threads.
      # stop_signal in a list so the reference is shared.
      actor_threads = []
      stop_signal = [False]
      for i in range(NUM_ACTORS):
          actor = actor_lib.Actor(
              agent,
              build_env(),
              UNROLL_LENGTH,
              learner,
              rng_seed=i,
              logger=util.AbslLogger(),  # Provide your own logger here.
          )
          args = (actor, stop_signal)
          actor_threads.append(
              threading.Thread(target=run_actor, args=args)
          )
  
      # Start the actors and learner.
      for t in actor_threads:
          t.start()
      learner.run(int(max_updates))
  
      # Stop.
      stop_signal[0] = True
      for t in actor_threads:
          t.join()
  
file_path: dm-haiku/examples/impala/run_catch.py
imports: import threading
  from absl import app
  from bsuite.environments import catch
  from examples.impala import actor
  from examples.impala import agent
  from examples.impala import haiku_nets
  from examples.impala import learner
  from examples.impala import util
  import jax
  import optax
label_desc: Use image node_id 2 for calling a global function with example usage: main(_) without return types