class_docstr: Observation and action spaces. Describes valid actions and observations.
  Similar to :gym:`gym.Space <#spaces>`.
  
  Args:
      shape (optional): Shape of the space, a tuple. If not
          given, infers from :attr:`low` and :attr:`high`.
      low (optional): Lower bound (inclusive) of each dimension of the
          space. Must have
          shape as specified by :attr:`shape`, and of the same shape with
          with :attr:`high` (if given). If `None`, set to `-inf` for each
          dimension.
      high (optional): Upper bound (inclusive) of each dimension of the
          space. Must have
          shape as specified by :attr:`shape`, and of the same shape with
          with :attr:`low` (if given). If `None`, set to `inf` for each
          dimension.
      dtype (optional): Data type of elements in the space. If not given,
          infers from :attr:`low` (if given) or set to `float`.
  
  Example:
  
      .. code-block:: python
  
          s = Space(low=0, high=10, dtype=np.int32)
          #s.contains(2) == True
          #s.contains(10) == True
          #s.contains(11) == False
          #s.shape == ()
  
          s2 = Space(shape=(2,2), high=np.ones([2,2]), dtype=np.float)
          #s2.low == [[-inf, -inf], [-inf, -inf]]
          #s2.high == [[1., 1.], [1., 1.]]
class_docstr_tok: ["Observation","and","action","spaces",".","Describes","valid","actions","and","observations",".","Similar","to",":","gym",":","`","gym.Space","<","#","spaces",">","`",".","Args",":","shape","(","optional",")",":","Shape","of","the","space",",","a","tuple",".","If","not","given",",","infers","from",":","attr",":","`","low","`","and",":","attr",":","`","high","`",".","low","(","optional",")",":","Lower","bound","(","inclusive",")","of","each","dimension","of","the","space",".","Must","have","shape","as","specified","by",":","attr",":","`","shape","`",",","and","of","the","same","shape","with","with",":","attr",":","`","high","`","(","if","given",")",".","If","`","None","`",",","set","to","`","-inf","`","for","each","dimension",".","high","(","optional",")",":","Upper","bound","(","inclusive",")","of","each","dimension","of","the","space",".","Must","have","shape","as","specified","by",":","attr",":","`","shape","`",",","and","of","the","same","shape","with","with",":","attr",":","`","low","`","(","if","given",")",".","If","`","None","`",",","set","to","`","inf","`","for","each","dimension",".","dtype","(","optional",")",":","Data","type","of","elements","in","the","space",".","If","not","given",",","infers","from",":","attr",":","`","low","`","(","if","given",")","or","set","to","`","float","`",".","Example",":","..","code-block",":",":","python","s","=","Space","(","low=0",",","high=10",",","dtype=np.int32",")","#","s.contains","(","2",")","==","True","#","s.contains","(","10",")","==","True","#","s.contains","(","11",")","==","False","#","s.shape","==","(",")","s2","=","Space","(","shape=","(","2,2",")",",","high=np.ones","(","[","2,2","]",")",",","dtype=np.float",")","#","s2.low","==","[","[","-inf",",","-inf","]",",","[","-inf",",","-inf","]","]","#","s2.high","==","[","[","1.",",","1",".","]",",","[","1.",",","1",".","]","]"]
code: def __init__(self, shape=None, low=None, high=None, dtype=None):
      if low is None:
          low = -float("inf")
      if high is None:
          high = float("inf")
  
      if shape is None:
          low = np.asarray(low)
          high = np.asarray(high)
          if low.shape != high.shape:
              raise ValueError(
                  "`low` and `high` must have the same shape."
              )
          shape = low.shape
      else:
          shape = tuple(shape)
  
      if np.isscalar(low):
          low = low + np.zeros(shape, dtype=dtype)
      if np.isscalar(high):
          high = high + np.zeros(shape, dtype=dtype)
      if shape != low.shape or shape != high.shape:
          raise ValueError(
              "Shape inconsistent: shape={}, low.shape={}, high.shape={}".format(
                  shape, low.shape, high.shape
              )
          )
      if dtype is None:
          dtype = low.dtype
      dtype = np.dtype(dtype)
      low = low.astype(dtype)
      high = high.astype(dtype)
      self._shape = shape
      self._low = low
      self._high = high
      self._dtype = dtype
  
file_path: texar/texar/tf/agents/agent_utils.py
imports: import numpy
label_desc: Use image node_id 1 to create a new Space object from inherited base classes: object with example: obj = Space(shape, low, high, dtype)