class_docstr: A tuple (more precisely: the cartesian product) of :class:`Space` instances.
  
  Elements of this space are tuples of elements of the constituent spaces.
  
  Example usage::
  
      >>> from gym.spaces import Box, Discrete
      >>> observation_space = Tuple((Discrete(2), Box(-1, 1, shape=(2,))))
      >>> observation_space.sample()
      (0, array([0.03633198, 0.42370757], dtype=float32))
class_docstr_tok: ["A","tuple","(","more","precisely",":","the","cartesian","product",")","of",":","class",":","`","Space","`","instances",".","Elements","of","this","space","are","tuples","of","elements","of","the","constituent","spaces",".","Example","usage",":",":",">",">",">","from","gym.spaces","import","Box",",","Discrete",">",">",">","observation_space","=","Tuple","(","(","Discrete","(","2",")",",","Box","(","-1",",","1",",","shape=","(","2",",",")",")",")",")",">",">",">","observation_space.sample","(",")","(","0",",","array","(","[","0.03633198",",","0.42370757","]",",","dtype=float32",")",")"]
docstr: Generates a single random sample inside this space.
  
  This method draws independent samples from the subspaces.
  
  Args:
      mask: An optional tuple of optional masks for each of the subspace's samples,
          expects the same number of masks as spaces
  
  Returns:
      Tuple of the subspace's samples
docstr_tok: ["Generates","a","single","random","sample","inside","this","space",".","This","method","draws","independent","samples","from","the","subspaces",".","Args",":","mask",":","An","optional","tuple","of","optional","masks","for","each","of","the","subspace","'s","samples",",","expects","the","same","number","of","masks","as","spaces","Returns",":","Tuple","of","the","subspace","'s","samples"]
code: def sample(
      self,
      mask: Optional[TypingTuple[Optional[np.ndarray], ...]] = None,
  ) -> tuple:
      """Generates a single random sample inside this space.
  
      This method draws independent samples from the subspaces.
  
      Args:
          mask: An optional tuple of optional masks for each of the subspace's samples,
              expects the same number of masks as spaces
  
      Returns:
          Tuple of the subspace's samples
      """
      if mask is not None:
          assert isinstance(
              mask, tuple
          ), f"Expected type of mask is tuple, actual type: {type(mask)}"
          assert len(mask) == len(
              self.spaces
          ), f"Expected length of mask is {len(self.spaces)}, actual length: {len(mask)}"
  
          return tuple(
              space.sample(mask=sub_mask)
              for space, sub_mask in zip(self.spaces, mask)
          )
  
      return tuple(space.sample() for space in self.spaces)
  
imports: from collections.abc import Sequence
  from typing import Iterable, Optional
  from typing import Sequence
  from typing import Tuple
  from typing import Union
  import numpy
  from gym.spaces.space import Space
label_desc: Use image node_id 4 for calling the Tuple obj's underlying member method code with example usage: obj.sample(mask) and returns: tuple, tuple