class_docstr: Abstract dataset class. All datasets should have this interface.
  
  Subclasses need to override `__getitem__`, which returns the i-th
  element, and `__len__`, which returns the total number elements.
  
  .. note:: An mxnet or numpy array can be directly used as a dataset.
docstr: Returns a new dataset with elements sampled by the sampler.
  
  Parameters
  ----------
  sampler : Sampler
      A Sampler that returns the indices of sampled elements.
  
  Returns
  -------
  Dataset
      The result dataset.
docstr_tok: ["Returns","a","new","dataset","with","elements","sampled","by","the","sampler",".","Parameters","--","--","--","--","--","sampler",":","Sampler","A","Sampler","that","returns","the","indices","of","sampled","elements",".","Returns","--","--","--","-","Dataset","The","result","dataset","."]
code: def sample(self, sampler):
      """Returns a new dataset with elements sampled by the sampler.
  
      Parameters
      ----------
      sampler : Sampler
          A Sampler that returns the indices of sampled elements.
  
      Returns
      -------
      Dataset
          The result dataset.
      """
      from . import Sampler
  
      if not isinstance(sampler, Sampler):
          raise TypeError(
              f"Invalid sampler type: {type(sampler)}. Expected gluon.data.Sampler instead."
          )
      return _SampledDataset(self, sampler)
  
imports: import os
  from ...None import recordio, ndarray
  from ...util import default_array
label_desc: Use image node_id 6 for calling the Dataset obj's underlying member method code with example usage: obj.sample(sampler) and returns: _SampledDataset