code: def _subproc_worker(
      pipe,
      parent_pipe,
      env_fn_wrapper,
      obs_bufs,
      obs_shapes,
      obs_dtypes,
      keys,
  ):
      """
      Control a single environment instance using IPC and
      shared memory.
      """
  
      def _write_obs(maybe_dict_obs):
          flatdict = obs_to_dict(maybe_dict_obs)
          for k in keys:
              dst = obs_bufs[k].get_obj()
              dst_np = np.frombuffer(dst, dtype=obs_dtypes[k]).reshape(
                  obs_shapes[k]
              )  # pylint: disable=W0212
              np.copyto(dst_np, flatdict[k])
  
      env = env_fn_wrapper.x()
      parent_pipe.close()
      try:
          while True:
              cmd, data = pipe.recv()
              if cmd == "reset":
                  pipe.send(_write_obs(env.reset()))
              elif cmd == "step":
                  obs, reward, done, info = env.step(data)
                  if done:
                      obs = env.reset()
                  pipe.send((_write_obs(obs), reward, done, info))
              elif cmd == "render":
                  pipe.send(env.render(mode="rgb_array"))
              elif cmd == "close":
                  pipe.send(None)
                  break
              else:
                  raise RuntimeError("Got unrecognized cmd %s" % cmd)
      except KeyboardInterrupt:
          print("ShmemVecEnv worker: got KeyboardInterrupt")
      finally:
          env.close()
  
file_path: baselines/baselines/common/vec_env/shmem_vec_env.py
imports: import multiprocessing
  import numpy
  from .vec_env import VecEnv, CloudpickleWrapper, clear_mpi_env_vars
  import ctypes
  from baselines import logger
  from .util import dict_to_obs, obs_space_info, obs_to_dict
label_desc: Use image node_id 1 for calling a global function with example usage: _subproc_worker(pipe, parent_pipe, env_fn_wrapper, obs_bufs, obs_shapes, obs_dtypes, keys) without return types