docs: def sample(self, nsamples=100, seed=None):
          """
          Extract a random sample of images.
  
          Parameters
          ----------
          nsamples : int, optional, default = 100
              The number of data points to sample.
  
          seed : int, optional, default = None
              Random seed.
          """
          if nsamples < 1:
              raise ValueError("Number of samples must be larger than 0, got '%g'" % nsamples)
  
          if seed is None:
              seed = random.randint(0, 2 ** 32)
  
          if self.mode == 'spark':
              result = asarray(self.values.tordd().values().takeSample(False, nsamples, seed))
  
          else:
              inds = [int(k) for k in random.rand(nsamples) * self.shape[0]]
              result = asarray([self.values[i] for i in inds])
  
          return self._constructor(result)