code: def main(opts, **kwargs):
      # defaults are for CPU
      dev_id = getattr(opts, "dev.device_id", torch.device("cpu"))
      device = getattr(opts, "dev.device", torch.device("cpu"))
      use_distributed = getattr(opts, "ddp.use_distributed")
  
      is_master_node = is_master(opts)
  
      # set-up data loaders
      val_loader = create_test_loader(opts)
  
      # set-up the model and print information
      model = get_model(opts)
      if is_master_node:
          model.info()
  
      # memory format
      memory_format = (
          torch.channels_last
          if getattr(opts, "common.channels_last", False)
          else torch.contiguous_format
      )
      model = model.to(device=device, memory_format=memory_format)
  
      if use_distributed:
          model = model.to(device=device, memory_format=memory_format)
          model = torch.nn.parallel.DistributedDataParallel(
              model,
              device_ids=[dev_id],
              output_device=dev_id,
              find_unused_parameters=getattr(
                  opts, "ddp.find_unused_params", False
              ),
          )
          if is_master_node:
              logger.log("Using DistributedDataParallel for training")
  
      # setup criteria and print its information
      criteria = build_loss_fn(opts)
      if is_master_node:
          logger.log(logger.color_text("Loss function"))
          print(criteria)
  
      criteria = criteria.to(device=device)
  
      training_engine = Trainer(
          opts=opts,
          model=model,
          validation_loader=val_loader,
          training_loader=None,
          optimizer=None,
          criterion=criteria,
          scheduler=None,
          start_epoch=0,
          start_iteration=0,
          best_metric=0,
          model_ema=None,
          gradient_scaler=None,
      )
      training_engine.run_loss_landscape()
  
file_path: ml-cvnets/main_loss_landscape.py
imports: from typing import List, Optional
  import torch
  from cvnets import get_model
  from data import create_test_loader
  from engine import Trainer
  from loss_fn import build_loss_fn
  from options.opts import get_loss_landscape_args
  from utils import logger, resources
  from utils.common_utils import create_directories, device_setup
  from utils.ddp_utils import distributed_init, is_master
label_desc: Use image node_id 1 for calling a global function with example usage: main(opts) without return types