code: def main(
      train_dir: Path,
      val_dir: Path,
      log_dir: Path,
      batch_size_per_device: int,
      epochs: int,
      num_workers: int,
      accelerator: str,
      devices: int,
      precision: str,
      compile_model: bool,
      methods: Union[Sequence[str], None],
      num_classes: int,
      skip_knn_eval: bool,
      skip_linear_eval: bool,
      skip_finetune_eval: bool,
      ckpt_path: Union[Path, None],
  ) -> None:
      torch.set_float32_matmul_precision("high")
  
      method_names = methods or METHODS.keys()
  
      for method in method_names:
          method_dir = (
              log_dir
              / method
              / datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
          ).resolve()
          model = METHODS[method]["model"](
              batch_size_per_device=batch_size_per_device,
              num_classes=num_classes,
          )
  
          if compile_model and hasattr(torch, "compile"):
              # Compile model if PyTorch supports it.
              print_rank_zero("Compiling model...")
              model = torch.compile(model)
  
          if epochs <= 0:
              print_rank_zero("Epochs <= 0, skipping pretraining.")
              if ckpt_path is not None:
                  model.load_state_dict(
                      torch.load(ckpt_path)["state_dict"]
                  )
          else:
              pretrain(
                  model=model,
                  method=method,
                  train_dir=train_dir,
                  val_dir=val_dir,
                  log_dir=method_dir,
                  batch_size_per_device=batch_size_per_device,
                  epochs=epochs,
                  num_workers=num_workers,
                  accelerator=accelerator,
                  devices=devices,
                  precision=precision,
                  ckpt_path=ckpt_path,
              )
  
          if skip_knn_eval:
              print_rank_zero("Skipping KNN eval.")
          else:
              knn_eval.knn_eval(
                  model=model,
                  num_classes=num_classes,
                  train_dir=train_dir,
                  val_dir=val_dir,
                  log_dir=method_dir,
                  batch_size_per_device=batch_size_per_device,
                  num_workers=num_workers,
                  accelerator=accelerator,
                  devices=devices,
              )
  
          if skip_linear_eval:
              print_rank_zero("Skipping linear eval.")
          else:
              linear_eval.linear_eval(
                  model=model,
                  num_classes=num_classes,
                  train_dir=train_dir,
                  val_dir=val_dir,
                  log_dir=method_dir,
                  batch_size_per_device=batch_size_per_device,
                  num_workers=num_workers,
                  accelerator=accelerator,
                  devices=devices,
                  precision=precision,
              )
  
          if skip_finetune_eval:
              print_rank_zero("Skipping fine-tune eval.")
          else:
              finetune_eval.finetune_eval(
                  model=model,
                  num_classes=num_classes,
                  train_dir=train_dir,
                  val_dir=val_dir,
                  log_dir=method_dir,
                  batch_size_per_device=batch_size_per_device,
                  num_workers=num_workers,
                  accelerator=accelerator,
                  devices=devices,
                  precision=precision,
              )
  
imports: from argparse import ArgumentParser
  from datetime import datetime
  from pathlib import Path
  from typing import Sequence, Union
  import barlowtwins
  import byol
  import dcl
  import dclw
  import dino
  import finetune_eval
  import knn_eval
  import linear_eval
  import mocov2
  import simclr
  import swav
  import tico
  import torch
  import vicreg
  from pytorch_lightning import LightningModule, Trainer
  from pytorch_lightning.callbacks import DeviceStatsMonitor, EarlyStopping, LearningRateMonitor
  from pytorch_lightning.loggers import TensorBoardLogger
  from torch.utils.data import DataLoader
  from torchvision import transforms
  from lightly.data import LightlyDataset
  from lightly.transforms.utils import IMAGENET_NORMALIZE
  from lightly.utils.benchmarking import MetricCallback
  from lightly.utils.dist import print_rank_zero
label_desc: Use image node_id 1 for calling a global function with example usage: main(train_dir, val_dir, log_dir, batch_size_per_device, epochs, num_workers, accelerator, devices, precision, compile_model, methods, num_classes, skip_knn_eval, skip_linear_eval, skip_finetune_eval, ckpt_path) without return types