code: def test_regnet(temp_files, ddp_ref, precision, flatten, sync_bn):
      if torch_version() < (1, 8, 0):
          pytest.skip("pytorch version >= 1.8.0 required")
  
      (
          state_before,
          inputs,
          conv_bias,
          linear_bias,
          state_after,
      ) = ddp_ref
  
      state_after = state_after[(precision, sync_bn)]
  
      fsdp_config = {}
      fsdp_config["mixed_precision"] = precision == "mixed"
      fsdp_config["flatten_parameters"] = flatten == "flatten"
  
      # When linear bias is True, DDP's AMP O1 and FSDP's default AMP O1.5 is different,
      # we force FSDP to use AMP O1 here by setting compute_dtype to float32.
      if linear_bias:
          fsdp_config["compute_dtype"] = torch.float32
  
      if fsdp_config["mixed_precision"] and torch_cuda_version() < (
          11,
          0,
      ):
          pytest.skip("Only CUDA 11 is supported with AMP equivalency")
  
      # Wrap BN half of the time.
      wrap_bn = True
      if random.randint(0, 1) == 0:
          wrap_bn = False
      # Except, always wrap BN in mixed precision + sync_bn mode, due to error of sync_bn wrapping,
      # regardless of compute_dtype.
      if fsdp_config["mixed_precision"] and sync_bn != "none":
          wrap_bn = True
  
      # When BN is not wrapped (i.e. not in full precision), FSDP's compute_dtype needs to
      # be fp32 to match DDP (otherwise, numerical errors happen on BN's running_mean/running_var
      # buffers).
      if fsdp_config["mixed_precision"] and not wrap_bn:
          fsdp_config["compute_dtype"] = torch.float32
  
      world_size = _world_size
      mp.spawn(
          _distributed_worker,
          args=(
              world_size,
              fsdp_config,
              wrap_bn,
              None,
              temp_files[0],
              temp_files[1],
              state_before,
              inputs,
              None,
              state_after,
              sync_bn,
              conv_bias,
              linear_bias,
          ),
          nprocs=world_size,
          join=True,
      )
  
imports: import contextlib
  from itertools import product
  import random
  import tempfile
  import pytest
  import torch
  from torch.cuda.amp import GradScaler
  import torch.multiprocessing
  from torch.nn import AdaptiveAvgPool2d, BatchNorm2d, Conv2d, CrossEntropyLoss, Linear, Module, ReLU, Sequential, Sigmoid, SyncBatchNorm
  from torch.nn.parallel import DistributedDataParallel
  from torch.optim import SGD
  from fairscale.fair_dev.testing.testing import dist_init, objects_are_equal, rmf, skip_if_single_gpu, state_dict_norm, teardown, torch_cuda_version
  from fairscale.internal import torch_version
  from fairscale.nn.data_parallel import FullyShardedDataParallel
  from fairscale.nn.data_parallel import TrainingState, auto_wrap_bn
label_desc: Use image node_id 4 for calling a global function with example usage: test_regnet(temp_files, ddp_ref, precision, flatten, sync_bn) without return types