class_docstr: Wrapper to get desired number of samples from underlying dataset only considering
  samples P for which mask[P] equals True
class_docstr_tok: ["Wrapper","to","get","desired","number","of","samples","from","underlying","dataset","only","considering","samples","P","for","which","mask","[","P","]","equals","True"]
code: def __init__(
      self, dataset: Dataset, mask: np.ndarray, num_samples: int
  ):
      if (
          not isinstance(mask, np.ndarray)
          or mask.dtype != np.bool
          or len(mask.shape) != 1
          or len(mask) != len(dataset)
      ):
          raise ValueError("Mask must be boolean 1-D numpy array")
  
      if not mask.any():
          raise ValueError("Mask must have at least one positive value")
  
      self.dataset = dataset
      self.mask = mask
      self.num_samples = num_samples
      self.indexes = np.flatnonzero(self.mask)
  
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 RandomSubsetWithMaskDataset object from inherited base classes: Dataset with example: obj = RandomSubsetWithMaskDataset(dataset, mask, num_samples)