class_docstr: Wrapper to get desired number of samples from underlying dataset
class_docstr_tok: ["Wrapper","to","get","desired","number","of","samples","from","underlying","dataset"]
code: def __init__(
      self,
      dataset,
      num_samples: int,
      weights: Optional[np.ndarray] = None,
  ):
      if weights is not None:
          if len(dataset) != len(weights):
              raise ValueError(
                  "Length of weights must be equal to length of dataset. Got {} and {}".format(
                      len(weights), len(dataset)
                  )
              )
      self.dataset = dataset
      self.num_samples = num_samples
      self.weights = np.cumsum(weights) if weights is not None else None
  
file_path: pytorch-toolbelt/pytorch_toolbelt/datasets/wrappers.py
imports: import random
  import typing
  from typing import Any, Optional
  from torch.utils.data import Dataset
  import numpy
  from torch.utils.data.dataloader import default_collate
label_desc: Use image node_id 1 to create a new RandomSubsetDataset object from inherited base classes: Dataset with example: obj = RandomSubsetDataset(dataset, num_samples, weights)