code: def test_num_samples(self):
      data = [1, 2, 3, 4, 5]
      weights = [1, 2, 3, 4, 5]
      sampler = DistributedWeightedRandomSampler(
          weights=weights,
          num_samples_per_rank=5,
          dataset=data,
          shuffle=False,
          generator=torch.Generator().manual_seed(123),
      )
      samples = np.array([data[i] for i in list(sampler)])
  
      if dist.get_rank() == 0:
          np.testing.assert_allclose(samples, np.array([3, 1, 5, 1, 5]))
  
      if dist.get_rank() == 1:
          np.testing.assert_allclose(samples, np.array([4, 2, 4, 2, 4]))
  
file_path: MONAI/tests/test_weighted_random_sampler_dist.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  import torch.distributed
  from monai.data import DistributedWeightedRandomSampler
  from tests.utils import DistCall, DistTestCase, skip_if_darwin, skip_if_windows
label_desc: Use image node_id 2 for calling the DistributedWeightedRandomSamplerTest obj's underlying member method code with example usage: obj.test_num_samples() without return types