class_docstr: Samples elements randomly. If without replacement, then sample from a shuffled dataset.
  If with replacement, then user can specify :attr:`num_samples` to draw.
  
  Args:
      data_source (Dataset): dataset to sample from
      replacement (bool): samples are drawn on-demand with replacement if ``True``, default=``False``
      num_samples (int): number of samples to draw, default=`len(dataset)`. This argument
          is supposed to be specified only when `replacement` is ``True``.
      generator (Generator): Generator used in sampling.
class_docstr_tok: ["Samples","elements","randomly",".","If","without","replacement",",","then","sample","from","a","shuffled","dataset",".","If","with","replacement",",","then","user","can","specify",":","attr",":","`","num_samples","`","to","draw",".","Args",":","data_source","(","Dataset",")",":","dataset","to","sample","from","replacement","(","bool",")",":","samples","are","drawn","on-demand","with","replacement","if","``","True","``",",","default=","``","False","``","num_samples","(","int",")",":","number","of","samples","to","draw",",","default=","`","len","(","dataset",")","`",".","This","argument","is","supposed","to","be","specified","only","when","`","replacement","`","is","``","True","``",".","generator","(","Generator",")",":","Generator","used","in","sampling","."]
code: def num_samples(self):
      # dataset size might change at runtime
      if self._num_samples is None:
          return len(self.data_source)
      return self._num_samples
  
imports: from typing import Iterator, Optional, Sized, Sequence
  import math
  from ....utils import require_not_none
label_desc: Use image node_id 2 for calling the RandomSampler obj's underlying member method code with example usage: obj.num_samples() and returns: self, len