class_docstr: Test the Regnet FSDP model in comparison with the DDP Regnet
  to verify that both converge to the same losses
class_docstr_tok: ["Test","the","Regnet","FSDP","model","in","comparison","with","the","DDP","Regnet","to","verify","that","both","converge","to","the","same","losses"]
code: def _pretraining_worker(
      gpu_id: int,
      with_fsdp: bool,
      with_activation_checkpointing: bool,
      with_larc: bool,
      sync_file: str,
      result_file: str,
  ):
      init_distributed_on_file(
          world_size=2, gpu_id=gpu_id, sync_file=sync_file
      )
      torch.manual_seed(0)
      torch.backends.cudnn.deterministic = True
  
      # Create the inputs
      batch = torch.randn(size=(8, 3, 224, 224)).cuda()
      target = torch.tensor(0.0).cuda()
  
      # Create a fake model based on SWAV blocks
      config = TestRegnetFSDP._create_pretraining_config(
          with_fsdp, with_activation_checkpointing, with_larc=with_larc
      )
      model = build_model(config["MODEL"], config["OPTIMIZER"])
      model = model.cuda()
      if with_fsdp:
          model = fsdp_wrapper(model, **config.MODEL.FSDP_CONFIG)
      else:
          model = DistributedDataParallel(model, device_ids=[gpu_id])
      criterion = SwAVLoss(loss_config=config["LOSS"]["swav_loss"])
      optimizer = build_optimizer(config["OPTIMIZER"])
      optimizer.set_param_groups(model.parameters())
  
      # Run a few iterations and collect the losses
      losses = []
      num_iterations = 5
      for iteration in range(num_iterations):
          out = model(batch)
          loss = criterion(out[0], target)
          if gpu_id == 0:
              losses.append(loss.item())
          optimizer.zero_grad()
          loss.backward()
          if iteration <= 2:
              for name, param in model.named_parameters():
                  if "prototypes" in name:
                      param.grad = None
          optimizer.step(where=float(iteration / num_iterations))
  
      # Store the losses in a file to compare several methods
      if gpu_id == 0:
          with open(result_file, "wb") as f:
              pickle.dump(losses, f)
  
file_path: vissl/tests/test_regnet_fsdp.py
imports: import pickle
  import unittest
  import torch
  import torch.multiprocessing
  from classy_vision.optim import build_optimizer
  from torch.nn.parallel import DistributedDataParallel
  from vissl.losses.swav_loss import SwAVLoss
  from vissl.models import build_model
  from vissl.optimizers import *
  from vissl.utils.fsdp_utils import fsdp_wrapper
  from vissl.utils.hydra_config import compose_hydra_configuration, convert_to_attrdict
  from vissl.utils.test_utils import gpu_test, init_distributed_on_file, with_temp_files
label_desc: Use image node_id 2 for calling the TestRegnetFSDP obj's underlying member method code with example usage: obj._pretraining_worker(gpu_id, with_fsdp, with_activation_checkpointing, with_larc, sync_file, result_file) without return types