Returns a reading spec of a gym space.

  NOTE: Only implemented currently for Box and Discrete.

  Args:
    gym_space: instance of gym.spaces whose spec we want.

  Returns:
    Reading spec for that space.

  Raises:
    NotImplementedError: For spaces whose reading spec we haven't implemented.

def gym_space_spec(gym_space):
  """Returns a reading spec of a gym space.

  NOTE: Only implemented currently for Box and Discrete.

  Args:
    gym_space: instance of gym.spaces whose spec we want.

  Returns:
    Reading spec for that space.

  Raises:
    NotImplementedError: For spaces whose reading spec we haven't implemented.
  """
  # First try to determine the type.
  try:
    tf_dtype = tf.as_dtype(gym_space.dtype)
  except TypeError as e:
    tf.logging.error("Cannot convert space's type [%s] to tf.dtype",
                     gym_space.dtype)
    raise e

  # Now hand it over to the specialized functions.
  if isinstance(gym_space, Box):
    return box_space_spec(gym_space, tf_dtype)
  elif isinstance(gym_space, Discrete):
    return discrete_space_spec(gym_space, tf_dtype)
  else:
    raise NotImplementedError