code: def setup_sampler(sampler_type, num_iters, batch_size):
      if sampler_type is None:
          return None, batch_size
  
      if sampler_type == "weighted":
          from torch.utils.data.sampler import WeightedRandomSampler
  
          w = torch.ones(num_iters * batch_size, dtype=torch.float)
          for i in range(num_iters):
              w[batch_size * i : batch_size * (i + 1)] += i * 1.0
          return (
              WeightedRandomSampler(
                  w,
                  num_samples=num_iters * batch_size,
                  replacement=True,
              ),
              batch_size,
          )
  
      if sampler_type == "distributed":
          import torch.distributed as dist
          from torch.utils.data.distributed import DistributedSampler
  
          num_replicas = 1
          rank = 0
          if dist.is_available() and dist.is_initialized():
              num_replicas = dist.get_world_size()
              rank = dist.get_rank()
  
          dataset = torch.zeros(num_iters * batch_size)
          return (
              DistributedSampler(
                  dataset, num_replicas=num_replicas, rank=rank
              ),
              batch_size // num_replicas,
          )
  
file_path: ignite/tests/ignite/engine/__init__.py
imports: import torch
label_desc: Use image node_id 1 for calling a global function with example usage: setup_sampler(sampler_type, num_iters, batch_size) and returns: None,  batch_size, WeightedRandomSampler,  batch_size, DistributedSampler,  unknown