code: def _test_distrib_one_rank_only(device):
      def _test(barrier):
          # last rank
          rank = idist.get_world_size() - 1
  
          value = torch.tensor(0).to(device)
  
          @idist.one_rank_only(rank=rank, with_barrier=barrier)
          def initialize():
              value.add_(torch.tensor(100).to(device))
  
          initialize()
  
          value_list = idist.all_gather(tensor=value)
  
          for r in range(idist.get_world_size()):
              if r == rank:
                  assert value_list[r].item() == 100
              else:
                  assert value_list[r].item() == 0
  
      _test(barrier=True)
      _test(barrier=False)
  
file_path: ignite/tests/ignite/distributed/utils/__init__.py
imports: import pytest
  import torch
  import torch.distributed
  import ignite.distributed
  from ignite.distributed.utils import sync
  from ignite.engine import Engine, Events
label_desc: Use image node_id 12 for calling a global function with example usage: _test_distrib_one_rank_only(device) without return types