code: def cli_main():
      pl.seed_everything(1234)
  
      # args
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "-c",
          "--config",
          default=None,
          type=str,
          help="config file path (default: None)",
      )
      parser.add_argument(
          "-r",
          "--resume",
          default=None,
          type=str,
          help="path to latest checkpoint (default: None)",
      )
      parser.add_argument(
          "-d",
          "--device",
          default=None,
          type=str,
          help="indices of GPUs to enable (default: None)",
      )
      parser.add_argument(
          "--num_workers",
          default=10,
          type=int,
          help="number of workers used in the data loader (default: 10)",
      )
      parser.add_argument(
          "-e",
          "--n_epochs",
          default=100,
          type=int,
          help="if given, override the num",
      )
  
      args = parser.parse_args()
      config = json.load(open(args.config))
  
      if args.device is not None:
          config["device"] = args.device
  
      # data
      def get_instance(module, name, config, *args, **kwargs):
          return getattr(module, config[name]["type"])(
              *args, **config[name]["args"], **kwargs
          )
  
      dataset = get_instance(module_data, "dataset", config)
      val_dataset = get_instance(
          module_data, "dataset", config, train=False
      )
  
      data_loader = DataLoader(
          dataset,
          batch_size=int(config["batch_size"]),
          num_workers=args.num_workers,
          shuffle=True,
          drop_last=True,
          pin_memory=True,
      )
  
      valid_data_loader = DataLoader(
          val_dataset,
          batch_size=config["batch_size"],
          num_workers=args.num_workers,
          shuffle=False,
      )
      # model
      model = ToxicClassifier(config)
  
      # training
  
      checkpoint_callback = ModelCheckpoint(
          save_top_k=100,
          verbose=True,
          monitor="val_loss",
          mode="min",
      )
      trainer = pl.Trainer(
          gpus=args.device,
          max_epochs=args.n_epochs,
          accumulate_grad_batches=config["accumulate_grad_batches"],
          callbacks=[checkpoint_callback],
          resume_from_checkpoint=args.resume,
          default_root_dir="saved/" + config["name"],
          deterministic=True,
      )
      trainer.fit(model, data_loader, valid_data_loader)
  
imports: import argparse
  import json
  import os
  import pytorch_lightning
  import src.data_loaders
  import torch
  from pytorch_lightning.callbacks import ModelCheckpoint
  from src.utils import get_model_and_tokenizer
  from torch.nn import functional
  from torch.utils.data import DataLoader
label_desc: Use image node_id 1 for calling a global function with example usage: cli_main() and returns: getattr