class_docstr: An n-shape binary space.
  
  Elements of this space are binary arrays of a shape that is fixed during construction.
  
  Example Usage::
  
      >>> observation_space = MultiBinary(5)
      >>> observation_space.sample()
          array([0, 1, 0, 1, 0], dtype=int8)
      >>> observation_space = MultiBinary([3, 2])
      >>> observation_space.sample()
          array([[0, 0],
              [0, 1],
              [1, 1]], dtype=int8)
class_docstr_tok: ["An","n-shape","binary","space",".","Elements","of","this","space","are","binary","arrays","of","a","shape","that","is","fixed","during","construction",".","Example","Usage",":",":",">",">",">","observation_space","=","MultiBinary","(","5",")",">",">",">","observation_space.sample","(",")","array","(","[","0",",","1",",","0",",","1",",","0","]",",","dtype=int8",")",">",">",">","observation_space","=","MultiBinary","(","[","3",",","2","]",")",">",">",">","observation_space.sample","(",")","array","(","[","[","0",",","0","]",",","[","0",",","1","]",",","[","1",",","1","]","]",",","dtype=int8",")"]
docstr: Constructor of :class:`MultiBinary` space.
  
  Args:
      n: This will fix the shape of elements of the space. It can either be an integer (if the space is flat)
          or some sort of sequence (tuple, list or np.ndarray) if there are multiple axes.
      seed: Optionally, you can use this argument to seed the RNG that is used to sample from the space.
docstr_tok: ["Constructor","of",":","class",":","`","MultiBinary","`","space",".","Args",":","n",":","This","will","fix","the","shape","of","elements","of","the","space",".","It","can","either","be","an","integer","(","if","the","space","is","flat",")","or","some","sort","of","sequence","(","tuple",",","list","or","np.ndarray",")","if","there","are","multiple","axes",".","seed",":","Optionally",",","you","can","use","this","argument","to","seed","the","RNG","that","is","used","to","sample","from","the","space","."]
code: def __init__(
      self,
      n: Union[np.ndarray, Sequence[int], int],
      seed: Optional[Union[int, np.random.Generator]] = None,
  ):
      """Constructor of :class:`MultiBinary` space.
  
      Args:
          n: This will fix the shape of elements of the space. It can either be an integer (if the space is flat)
              or some sort of sequence (tuple, list or np.ndarray) if there are multiple axes.
          seed: Optionally, you can use this argument to seed the RNG that is used to sample from the space.
      """
      if isinstance(n, (Sequence, np.ndarray)):
          self.n = input_n = tuple(int(i) for i in n)
          assert (
              np.asarray(input_n) > 0
          ).all()  # n (counts) have to be positive
      else:
          self.n = n = int(n)
          input_n = (n,)
          assert (
              np.asarray(input_n) > 0
          ).all()  # n (counts) have to be positive
  
      super().__init__(input_n, np.int8, seed)
  
file_path: gym/gym/spaces/multi_binary.py
imports: from typing import Optional, Sequence, Tuple, Union
  import numpy
  from gym.spaces.space import Space
label_desc: Use image node_id 1 to create a new MultiBinary object from inherited base classes: Space with example: obj = MultiBinary(n, seed)