class_docstr: At every iteration, this will return m samples per class. For example,
  if dataloader's batchsize is 100, and m = 5, then 20 classes with 5 samples
  each will be returned
code: def __init__(
      self, labels, m, batch_size=None, length_before_new_iter=100000
  ):
      if isinstance(labels, torch.Tensor):
          labels = labels.numpy()
      self.m_per_class = int(m)
      self.batch_size = (
          int(batch_size) if batch_size is not None else batch_size
      )
      self.labels_to_indices = c_f.get_labels_to_indices(labels)
      self.labels = list(self.labels_to_indices.keys())
      self.length_of_single_pass = self.m_per_class * len(self.labels)
      self.list_size = length_before_new_iter
      if self.batch_size is None:
          if self.length_of_single_pass < self.list_size:
              self.list_size -= (self.list_size) % (
                  self.length_of_single_pass
              )
      else:
          assert self.list_size >= self.batch_size
          assert (
              self.length_of_single_pass >= self.batch_size
          ), "m * (number of unique labels) must be >= batch_size"
          assert (
              self.batch_size % self.m_per_class
          ) == 0, (
              "m_per_class must divide batch_size without any remainder"
          )
          self.list_size -= self.list_size % self.batch_size
  
file_path: pytorch-metric-learning/src/pytorch_metric_learning/samplers/m_per_class_sampler.py
imports: import torch
  from torch.utils.data.sampler import Sampler
  from ..utils import common_functions
label_desc: Use image node_id 1 to create a new MPerClassSampler object from inherited base classes: Sampler with example: obj = MPerClassSampler(labels, m, batch_size, length_before_new_iter)