code: def test_dist_proxy_sampler():
      weights = torch.ones(100)
      weights[:50] += 1
      num_samples = 200
      sampler = WeightedRandomSampler(weights, num_samples)
  
      num_replicas = 8
      dist_samplers = [
          DistributedProxySampler(
              sampler, num_replicas=num_replicas, rank=i
          )
          for i in range(num_replicas)
      ]
  
      for seed in range(100):
          torch.manual_seed(seed)
          true_indices = list(sampler)
  
          indices_per_rank = []
          for s in dist_samplers:
              s.set_epoch(seed)
              indices_per_rank += list(s)
  
          set_indices_per_rank = set(indices_per_rank)
          set_true_indices = set(true_indices)
          assert (
              set_indices_per_rank == set_true_indices
          ), f"{set_true_indices - set_indices_per_rank} | {set_indices_per_rank - set_true_indices}"
  
      with pytest.raises(
          TypeError,
          match=r"Argument sampler should be instance of torch Sampler",
      ):
          DistributedProxySampler(None)
  
      with pytest.raises(
          TypeError, match=r"Argument sampler should have length"
      ):
          DistributedProxySampler(Sampler([1]))
  
      with pytest.raises(
          TypeError,
          match=r"Argument sampler must not be a distributed sampler already",
      ):
          DistributedProxySampler(
              DistributedSampler(
                  sampler, num_replicas=num_replicas, rank=0
              )
          )
  
imports: import os
  import pytest
  import torch
  import torch.nn
  import torch.optim
  from torch.utils.data import DataLoader
  from torch.utils.data.dataloader import _InfiniteConstantSampler
  from torch.utils.data.dataset import Dataset, IterableDataset
  from torch.utils.data.distributed import DistributedSampler
  from torch.utils.data.sampler import BatchSampler, RandomSampler, Sampler, SequentialSampler, WeightedRandomSampler
  import ignite.distributed
  from ignite.distributed.auto import auto_dataloader, auto_model, auto_optim, DistributedProxySampler
label_desc: Use image node_id 14 for calling a global function with example usage: test_dist_proxy_sampler() without return types