code: def run_test_ddp_sync_batch_norm(
      rank, world_size, backend, device, temp_file_name
  ):
      dist.init_process_group(
          init_method="file://" + temp_file_name,
          backend=backend,
          rank=rank,
          world_size=world_size,
      )
  
      model = Sequential(
          Linear(2, 3), torch.nn.BatchNorm1d(3), Linear(3, 3)
      ).to(device)
      model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model)
      model.to(
          device
      )  # in pytorch 1.5 syncBN switches to the default device/cpu
  
      optimizer = OSS(
          params=model.parameters(),
          optim=torch.optim.SGD,
          lr=1e-3,
          momentum=0.99,
      )
      ddp_model = ShardedDataParallel(model, optimizer)
  
      assert isinstance(model[1], torch.nn.SyncBatchNorm)
      # Ensures sync batch norm handles have been added
      ddp_model(torch.randn(2, 2).to(device))
      dist.destroy_process_group()
  
imports: from contextlib import suppress
  import numpy
  import pytest
  import torch
  import torch.distributed
  import torch.multiprocessing
  from torch.nn import Linear, Sequential
  from fairscale.fair_dev.testing.testing import GPT2, SGDWithPausingCompute, available_devices, check_same_models_across_ranks, skip_if_less_than_four_gpu, skip_if_no_cuda, skip_if_single_gpu, temp_files_ctx
  from fairscale.nn.data_parallel import ShardedDataParallel
  from fairscale.optim import OSS
label_desc: Use image node_id 17 for calling a global function with example usage: run_test_ddp_sync_batch_norm(rank, world_size, backend, device, temp_file_name) without return types