class_docstr: A wrapper that allow to use dict observation space (coming from GoalEnv) with
  the RL algorithms.
  It assumes that all the spaces of the dict space are of the same type.
  
  :param env: (gym.GoalEnv)
code: def __init__(self, env):
      super(HERGoalEnvWrapper, self).__init__()
      self.env = env
      self.metadata = self.env.metadata
      self.action_space = env.action_space
      self.spaces = list(env.observation_space.spaces.values())
      # Check that all spaces are of the same type
      # (current limitation of the wrapper)
      space_types = [
          type(env.observation_space.spaces[key]) for key in KEY_ORDER
      ]
      assert len(set(space_types)) == 1, (
          "The spaces for goal and observation"
          " must be of the same type"
      )
  
      if isinstance(self.spaces[0], spaces.Discrete):
          self.obs_dim = 1
          self.goal_dim = 1
      else:
          goal_space_shape = env.observation_space.spaces[
              "achieved_goal"
          ].shape
          self.obs_dim = env.observation_space.spaces[
              "observation"
          ].shape[0]
          self.goal_dim = goal_space_shape[0]
  
          if len(goal_space_shape) == 2:
              assert (
                  goal_space_shape[1] == 1
              ), "Only 1D observation spaces are supported yet"
          else:
              assert (
                  len(goal_space_shape) == 1
              ), "Only 1D observation spaces are supported yet"
  
      if isinstance(self.spaces[0], spaces.MultiBinary):
          total_dim = self.obs_dim + 2 * self.goal_dim
          self.observation_space = spaces.MultiBinary(total_dim)
  
      elif isinstance(self.spaces[0], spaces.Box):
          lows = np.concatenate([space.low for space in self.spaces])
          highs = np.concatenate([space.high for space in self.spaces])
          self.observation_space = spaces.Box(
              lows, highs, dtype=np.float32
          )
  
      elif isinstance(self.spaces[0], spaces.Discrete):
          dimensions = [
              env.observation_space.spaces[key].n for key in KEY_ORDER
          ]
          self.observation_space = spaces.MultiDiscrete(dimensions)
  
      else:
          raise NotImplementedError(
              "{} space is not supported".format(type(self.spaces[0]))
          )
  
file_path: stable-baselines/stable_baselines/her/utils.py
imports: from collections import OrderedDict
  import numpy
  from gym import spaces
label_desc: Use image node_id 1 to create a new HERGoalEnvWrapper object from inherited base classes: object with example: obj = HERGoalEnvWrapper(env)