code: def test_mperclass_sampler(self):
      batch_size = 100
      m = 5
      length_before_new_iter = 9999
      num_labels = 100
      labels = torch.randint(low=0, high=num_labels, size=(10000,))
      sampler = MPerClassSampler(
          labels=labels,
          m=m,
          length_before_new_iter=length_before_new_iter,
      )
      self.assertTrue(
          len(sampler)
          == (m * num_labels)
          * (length_before_new_iter // (m * num_labels))
      )
      iterable = iter(sampler)
      for _ in range(10):
          x = [next(iterable) for _ in range(batch_size)]
          curr_labels = labels[x]
          unique_labels, counts = torch.unique(
              curr_labels, return_counts=True
          )
          self.assertTrue(len(unique_labels) == batch_size // m)
          self.assertTrue(torch.all(counts == m))
  
imports: import unittest
  import torch
  from pytorch_metric_learning.samplers import MPerClassSampler
  from pytorch_metric_learning.utils import common_functions
label_desc: Use image node_id 1 for calling the TestMPerClassSampler obj's underlying member method code with example usage: obj.test_mperclass_sampler() without return types