code: def test_separate_batches(self) -> None:
      indices = {
          rank: [
              i.item() for batch in self.samplers[rank] for i in batch
          ]
          for rank in range(self.world_size)
      }
      for rank1 in range(self.world_size):
          for rank2 in range(rank1 + 1, self.world_size):
              # Separate workers output separate indices
              self.assertEqual(
                  len(set(indices[rank1]) & set(indices[rank2])), 0
              )
  
      all_indices = set()
      for rank in range(self.world_size):
          all_indices |= set(indices[rank])
  
      # Note that with poisson sampling, the proportion of distinct samples seen during one epoch (1 - 1/e)
      # So the number of distinct samples is expected to be strictly less than the number of samples
      self.assertLessEqual(len(all_indices), self.data_size)
  
file_path: opacus/opacus/tests/distributed_poisson_test.py
imports: import unittest
  import numpy
  import torch
  from opacus.utils.uniform_sampler import DistributedUniformWithReplacementSampler
label_desc: Use image node_id 5 for calling the PoissonSamplingTest obj's underlying member method code with example usage: obj.test_separate_batches() without return types