code: def main(cfg: DictConfig) -> None:
      logging.info(f"\nConfig Params:\n{OmegaConf.to_yaml(cfg)}")
      try:
          strategy = NLPDDPStrategy(find_unused_parameters=True)
      except (ImportError, ModuleNotFoundError):
          strategy = "auto"
  
      trainer = pl.Trainer(strategy=strategy, **cfg.trainer)
      exp_manager(trainer, cfg.get("exp_manager", None))
  
      if not cfg.model.train_ds.file_path:
          raise ValueError(
              "'train_ds.file_path' need to be set for the training!"
          )
  
      model = TextClassificationModel(cfg.model, trainer=trainer)
      logging.info(
          "==========================================================================================="
      )
      logging.info("Starting training...")
      trainer.fit(model)
      logging.info("Training finished!")
      logging.info(
          "==========================================================================================="
      )
  
      if cfg.model.nemo_path:
          # '.nemo' file contains the last checkpoint and the params to initialize the model
          model.save_to(cfg.model.nemo_path)
          logging.info(
              f"Model is saved into `.nemo` file: {cfg.model.nemo_path}"
          )
  
      # We evaluate the trained model on the test set if test_ds is set in the config file
      if cfg.model.test_ds.file_path:
          logging.info(
              "==========================================================================================="
          )
          logging.info(
              "Starting the testing of the trained model on test set..."
          )
          trainer.test(model=model, ckpt_path=None, verbose=False)
          logging.info("Testing finished!")
          logging.info(
              "==========================================================================================="
          )
  
      # perform inference on a list of queries.
      if "infer_samples" in cfg.model and cfg.model.infer_samples:
          logging.info(
              "==========================================================================================="
          )
          logging.info(
              "Starting the inference on some sample queries..."
          )
  
          # max_seq_length=512 is the maximum length BERT supports.
          results = model.classifytext(
              queries=cfg.model.infer_samples,
              batch_size=16,
              max_seq_length=512,
          )
          logging.info(
              "The prediction results of some sample queries with the trained model:"
          )
          for query, result in zip(cfg.model.infer_samples, results):
              logging.info(f"Query : {query}")
              logging.info(f"Predicted label: {result}")
  
          logging.info("Inference finished!")
          logging.info(
              "==========================================================================================="
          )
  
imports: import pytorch_lightning
  from omegaconf import DictConfig, OmegaConf
  from nemo.collections.nlp.models.text_classification import TextClassificationModel
  from nemo.collections.nlp.parts.nlp_overrides import NLPDDPStrategy
  from nemo.core.config import hydra_runner
  from nemo.utils import logging
  from nemo.utils.exp_manager import exp_manager
label_desc: Use image node_id 1 for calling a global function with example usage: main(cfg) without return types