class_docstr: Unit and integration tests to check that the behavior of DINO is correct
  under FSDP.
class_docstr_tok: ["Unit","and","integration","tests","to","check","that","the","behavior","of","DINO","is","correct","under","FSDP","."]
code: def _create_dino_pretraining_config(
      with_fsdp: bool,
      with_mixed_precision: bool,
      with_multicrop: bool = False,
      with_mlp_checkpoints: bool = False,
      with_block_checkpoints: bool = False,
      gpu_count: int = 2,
      num_epochs: int = 2,
  ):
      main_config = "config=test/integration_test/quick_dino"
      if with_multicrop:
          main_config = (
              "config=test/integration_test/quick_dino_multicrop"
          )
  
      cfg = compose_hydra_configuration(
          [
              main_config,
              "config.SEED_VALUE=0",
              "config.DATA.TRAIN.DATA_SOURCES=[synthetic]",
              "config.DATA.TRAIN.BATCHSIZE_PER_REPLICA=4",
              "config.DATA.TRAIN.RANDOM_SYNTHETIC_IMAGES=True",
              "config.DATA.TRAIN.DATA_LIMIT=32",
              "config.DATA.TRAIN.USE_DEBUGGING_SAMPLER=True",
              "config.LOG_FREQUENCY=1",
              "config.REPRODUCIBILITY.CUDDN_DETERMINISTIC=True",
              f"config.OPTIMIZER.num_epochs={num_epochs}",
              f"config.DISTRIBUTED.NUM_PROC_PER_NODE={gpu_count}",
              # Activation checkpointing (memory optimisation)
              f"config.MODEL.TRUNK.VISION_TRANSFORMERS.CHECKPOINT_MLP={with_mlp_checkpoints}",
              f"config.MODEL.TRUNK.VISION_TRANSFORMERS.CHECKPOINT_BLOCK={with_block_checkpoints}",
              # Options to override to get FSDP
              "config.MODEL.TRUNK.NAME=vision_transformer",
              "config.MODEL.AMP_PARAMS.AMP_TYPE=pytorch",
              f"config.MODEL.AMP_PARAMS.USE_AMP={with_mixed_precision}",
              "config.MODEL.FSDP_CONFIG.AUTO_WRAP_THRESHOLD=0",
          ]
      )
      args, config = convert_to_attrdict(cfg)
      if with_fsdp:
          config["MODEL"]["TRUNK"]["NAME"] = "vision_transformer_fsdp"
          config["MODEL"]["HEAD"]["PARAMS"][0][0] = "dino_head_fsdp"
          config.TRAINER.TASK_NAME = "self_supervision_fsdp_task"
          config.MODEL.FSDP_CONFIG.flatten_parameters = False
          config.MODEL.FSDP_CONFIG.mixed_precision = (
              with_mixed_precision
          )
          config.MODEL.FSDP_CONFIG.fp32_reduce_scatter = (
              with_mixed_precision
          )
          config.MODEL.FSDP_CONFIG.compute_dtype = torch.float32
      return config
  
imports: import os
  import unittest
  import torch
  import torch.multiprocessing
  import torch.optim
  from torch.nn.parallel import DistributedDataParallel
  from vissl.models import build_model
  from vissl.models.heads.dino_head import DINOHead, DINOHeadFSDP
  from vissl.utils.checkpoint import CheckpointFormatConverter, DINOCheckpointUtils
  from vissl.utils.fsdp_utils import fsdp_wrapper
  from vissl.utils.hydra_config import compose_hydra_configuration, convert_to_attrdict
  from vissl.utils.misc import set_torch_seed
  from vissl.utils.test_utils import gpu_test, in_temporary_directory, init_distributed_on_file, run_integration_test, with_temp_files
label_desc: Use image node_id 1 for calling the TestDINO obj's underlying member method code with example usage: obj._create_dino_pretraining_config(with_fsdp, with_mixed_precision, with_multicrop, with_mlp_checkpoints, with_block_checkpoints, gpu_count, num_epochs) and returns: config