code: def chunk_X(
          self,
          select: Union[int, List[int], Tuple[int, ...], np.ndarray] = 1000,
          replace: bool = True,
      ):
          
          if isinstance(select, int):
              select = select if select < self.n_obs else self.n_obs
              choice = np.random.choice(self.n_obs, select, replace)
          elif isinstance(select, (np.ndarray, list, tuple)):
              choice = np.asarray(select)
          else:
              raise ValueError('select should be int or array')
  
          reverse = None
          if self.isbacked:
              # h5py can only slice with a sorted list of unique index values
              # so random batch with indices [2, 2, 5, 3, 8, 10, 8] will fail
              # this fixes the problem
              indices, reverse = np.unique(choice, return_inverse=True)
              selection = self.X[indices.tolist()]
          else:
              selection = self.X[choice]
  
          selection = selection.toarray() if issparse(selection) else selection
          return selection if reverse is None else selection[reverse]
docs: Return a chunk of the data matrix :attr:`X` with random or specified indices.
  
          Parameters
          ----------
          select
              If select is an integer, a random chunk of row size = select will be returned.
              If select is a list, tuple or numpy array of integers, then a chunk
              with these indices will be returned.
  
          replace
              If select is an integer then ``replace=True`` specifies random sampling of indices
              with replacement, ``replace=False`` - without replacement.