code: def _worker(remote, parent_remote, env_fn_wrapper):
      # switch to non-interactive matplotlib backend
      matplotlib.use("Agg")
  
      parent_remote.close()
      env: MazeEnv = env_fn_wrapper.var()
  
      # enable collection of logging statistics
      if not isinstance(env, LogStatsWrapper):
          env = LogStatsWrapper.wrap(env)
  
      # discard epoch-level statistics (as stats are shipped to the main process after each episode)
      env = disable_epoch_level_stats(env)
  
      while True:
          try:
              cmd, data = remote.recv()
              if cmd == "step":
                  observation, reward, env_done, info = env.step(data)
                  actor_done = env.is_actor_done()
                  actor_id = env.actor_id()
  
                  episode_stats = None
                  if env_done:
                      # save final observation where user can get it, then reset
                      info["terminal_observation"] = observation
                      observation = env.reset()
                      # collect episode stats after the reset
                      episode_stats = env.get_stats(
                          LogStatsLevel.EPISODE
                      ).last_stats
  
                  remote.send(
                      (
                          observation,
                          reward,
                          env_done,
                          info,
                          actor_done,
                          actor_id,
                          episode_stats,
                          env.get_env_time(),
                      )
                  )
              elif cmd == "seed":
                  env.seed(data)
              elif cmd == "reset":
                  observation = env.reset()
                  actor_done = env.is_actor_done()
                  actor_id = env.actor_id()
                  remote.send(
                      (
                          observation,
                          actor_done,
                          actor_id,
                          env.get_stats(
                              LogStatsLevel.EPISODE
                          ).last_stats,
                          env.get_env_time(),
                      )
                  )
              elif cmd == "close":
                  remote.close()
                  break
              elif cmd == "get_spaces":
                  remote.send(
                      (
                          env.observation_spaces_dict,
                          env.action_spaces_dict,
                          env.agent_counts_dict,
                      )
                  )
              elif cmd == "get_actor_rewards":
                  remote.send(env.get_actor_rewards())
              elif cmd == "env_method":
                  method = getattr(env, data[0])
                  remote.send(method(*data[1], **data[2]))
              elif cmd == "get_attr":
                  remote.send(getattr(env, data))
              elif cmd == "set_attr":
                  remote.send(setattr(env, data[0], data[1]))
              else:
                  raise NotImplementedError
          except EOFError:
              break
  
imports: import multiprocessing
  from typing import Callable, List, Iterable, Any, Tuple, Dict, Optional
  import cloudpickle
  import matplotlib
  import numpy
  from maze.core.annotations import override
  from maze.core.env.action_conversion import ActionType
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.observation_conversion import ObservationType
  from maze.core.log_stats.log_stats import LogStatsLevel
  from maze.core.wrappers.log_stats_wrapper import LogStatsWrapper
  from maze.train.parallelization.vector_env.structured_vector_env import StructuredVectorEnv
  from maze.train.parallelization.vector_env.vector_env import VectorEnv
  from maze.train.parallelization.vector_env.vector_env_utils import disable_epoch_level_stats
  from maze.train.utils.train_utils import stack_numpy_dict_list, unstack_numpy_list_dict
label_desc: Use image node_id 1 for calling a global function with example usage: _worker(remote, parent_remote, env_fn_wrapper) without return types