class_docstr: Wraps over another `Sampler` and return mini-batches of samples.
  
  Parameters
  ----------
  sampler : Sampler
      The source Sampler.
  batch_size : int
      Size of mini-batch.
  last_batch : {'keep', 'discard', 'rollover'}
      Specifies how the last batch is handled if batch_size does not evenly
      divide sequence length.
  
      If 'keep', the last batch will be returned directly, but will contain
      less element than `batch_size` requires.
  
      If 'discard', the last batch will be discarded.
  
      If 'rollover', the remaining elements will be rolled over to the next
      iteration.
  
  Examples
  --------
  >>> sampler = gluon.data.SequentialSampler(10)
  >>> batch_sampler = gluon.data.BatchSampler(sampler, 3, 'keep')
  >>> list(batch_sampler)
  [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
code: def __iter__(self):
      batch, self._prev = self._prev, []
      for i in self._sampler:
          batch.append(i)
          if len(batch) == self._batch_size:
              yield batch
              batch = []
      if batch:
          if self._last_batch == "keep":
              yield batch
          elif self._last_batch == "discard":
              return
          elif self._last_batch == "rollover":
              self._prev = batch
          else:
              raise ValueError(
                  "last_batch must be one of 'keep', 'discard', or 'rollover', "
                  f"but got {self._last_batch}"
              )
  
imports: import numpy
label_desc: Use image node_id 2 for calling the BatchSampler obj's underlying member method code with example usage: obj.__iter__() without return types