class_docstr: Constrained MNIST dataset.
  
  Args:
      num_samples: number of examples per selected class/digit
      digits: list selected MNIST digits/classes
      kwargs: Same as MNIST
  
  Examples:
      >>> dataset = TrialMNIST(".", download=True)
      >>> len(dataset)
      300
      >>> sorted(set([d.item() for d in dataset.targets]))
      [0, 1, 2]
      >>> torch.bincount(dataset.targets)
      tensor([100, 100, 100])
class_docstr_tok: ["Constrained","MNIST","dataset",".","Args",":","num_samples",":","number","of","examples","per","selected","class\/digit","digits",":","list","selected","MNIST","digits\/classes","kwargs",":","Same","as","MNIST","Examples",":",">",">",">","dataset","=","TrialMNIST","(","``",".","``",",","download=True",")",">",">",">","len","(","dataset",")","300",">",">",">","sorted","(","set","(","[","d.item","(",")","for","d","in","dataset.targets","]",")",")","[","0",",","1",",","2","]",">",">",">","torch.bincount","(","dataset.targets",")","tensor","(","[","100",",","100",",","100","]",")"]
code: def __init__(
      self,
      root: str,
      num_samples: int = 100,
      digits: Optional[Sequence] = (0, 1, 2),
      **kwargs,
  ):
      # number of examples per class
      self.num_samples = num_samples
      # take just a subset of MNIST dataset
      self.digits = sorted(digits) if digits else list(range(10))
  
      self.cache_folder_name = f"digits-{'-'.join(str(d) for d in self.digits)}_nb-{self.num_samples}"
  
      super().__init__(root, normalize=(0.5, 1.0), **kwargs)
  
imports: import logging
  import os
  import random
  import time
  import urllib.request
  from typing import Optional, Sequence, Tuple
  import torch
  from torch import Tensor
  from torch.utils.data import Dataset
label_desc: Use image node_id 1 to create a new TrialMNIST object from inherited base classes: MNIST with example: obj = TrialMNIST(root, num_samples, digits)