code: def test_perfect_sampler_shuffle(self):  # pylint: disable=no-self-use
      classes = set()
      for item in train_samples:
          classes.add(item["speaker_name"])
  
      sampler = PerfectBatchSampler(
          train_samples,
          classes,
          batch_size=2 * 3,  # total batch size
          num_classes_in_batch=2,
          label_key="speaker_name",
          shuffle=True,
          drop_last=False,
      )
      batchs = functools.reduce(
          lambda a, b: a + b, [list(sampler) for i in range(100)]
      )
      for batch in batchs:
          spk1, spk2 = 0, 0
          # for in each batch
          for index in batch:
              if train_samples[index]["speaker_name"] == "ljspeech-0":
                  spk1 += 1
              else:
                  spk2 += 1
          assert (
              spk1 == spk2
          ), "PerfectBatchSampler is supposed to be perfectly balanced"
  
file_path: TTS/tests/data_tests/test_samplers.py
imports: import functools
  import random
  import unittest
  import torch
  from TTS.config.shared_configs import BaseDatasetConfig
  from TTS.tts.datasets import load_tts_samples
  from TTS.tts.utils.data import get_length_balancer_weights
  from TTS.tts.utils.languages import get_language_balancer_weights
  from TTS.tts.utils.speakers import get_speaker_balancer_weights
  from TTS.utils.samplers import BucketBatchSampler, PerfectBatchSampler
label_desc: Use image node_id 5 for calling the TestSamplers obj's underlying member method code with example usage: obj.test_perfect_sampler_shuffle() without return types