def _map_actions(self, action):
    """Maps the given discrete action to the corresponding continuous action.

    Args:
      action: Discrete action to map.

    Returns:
      Numpy array with the mapped continuous actions.
    Raises:
      ValueError: If the given action's shpe does not match the action_spec
      shape.
    """
    action = np.asarray(action)
    if action.shape != self.action_space.shape:
      raise ValueError(
          "Received action with incorrect shape. Got {}, expected {}".format(
              action.shape, self.action_space.shape))

    mapped_action = [self._action_map[i][a]
                     for i, a in enumerate(action.flatten())]
    return np.reshape(mapped_action, newshape=action.shape)
Maps the given discrete action to the corresponding continuous action.

    Args:
      action: Discrete action to map.

    Returns:
      Numpy array with the mapped continuous actions.
    Raises:
      ValueError: If the given action's shpe does not match the action_spec
      shape.
    
tensor2tensor/rl/gym_utils.py