code: def setup_model_loss_criterion(cfg, args, rank, is_cuda):
      """
      setup model, criterion and optimizer based on input args
      """
      args.distributed_rank = rank
      cfg.distributed_training.distributed_rank = args.distributed_rank
      if cfg.distributed_training.distributed_world_size > 1:
          distributed_utils.distributed_init(cfg)
      torch.manual_seed(1)
      model = Model(args.input_size, args.nb_classes)
      loss_fn = nn.CrossEntropyLoss()
      if is_cuda:
          model = model.cuda()
          loss_fn = loss_fn.cuda()
  
      optimizer = optim.sgd.SGD(args, model.parameters())
      optimizer = optim.FairseqBMUF(cfg=cfg.bmuf, optimizer=optimizer)
  
      return model, loss_fn, optimizer
  
imports: import argparse
  import functools
  import random
  import unittest
  from multiprocessing import Manager
  import torch
  import torch.nn
  from omegaconf import OmegaConf
  from fairseq import optim
  from fairseq.distributed import utils
label_desc: Use image node_id 1 for calling a global function with example usage: setup_model_loss_criterion(cfg, args, rank, is_cuda) and returns: model,  loss_fn,  optimizer