code: def dict_to_obs(space, obs_dict):
      """
      Convert an internal representation raw_obs into the appropriate type
      specified by space.
  
      :param space: (gym.spaces.Space) an observation space.
      :param obs_dict: (OrderedDict<ndarray>) a dict of numpy arrays.
      :return (ndarray, tuple<ndarray> or dict<ndarray>): returns an observation
              of the same type as space. If space is Dict, function is identity;
              if space is Tuple, converts dict to Tuple; otherwise, space is
              unstructured and returns the value raw_obs[None].
      """
      if isinstance(space, gym.spaces.Dict):
          return obs_dict
      elif isinstance(space, gym.spaces.Tuple):
          assert len(obs_dict) == len(
              space.spaces
          ), "size of observation does not match size of observation space"
          return tuple((obs_dict[i] for i in range(len(space.spaces))))
      else:
          assert set(obs_dict.keys()) == {
              None
          }, "multiple observation keys for unstructured observation space"
          return obs_dict[None]
  
imports: from collections import OrderedDict
  import gym
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: dict_to_obs(space, obs_dict) and returns: obs_dict, tuple, obs_dict