code: def main(cfg: DictConfig) -> None:
      logging.info(f"Config Params: {OmegaConf.to_yaml(cfg)}")
      logging.info(
          "Start creating tar file from "
          + cfg.data.train_ds.data_path
          + " ..."
      )
      _, model = instantiate_model_and_trainer(
          cfg, MODEL, True
      )  # instantiate model like for training because we may not have pretrained model
      dataset = model._train_dl.dataset
      archive = tarfile.open(cfg.output_tar_file, mode="w")
      max_lines = int(cfg.take_first_n_lines)
      for i in range(len(dataset)):
          if i >= max_lines:
              logging.info("Reached " + str(max_lines) + " examples")
              break
          (
              input_ids,
              input_mask,
              segment_ids,
              input_ids_for_subwords,
              input_mask_for_subwords,
              segment_ids_for_subwords,
              character_pos_to_subword_pos,
              labels_mask,
              labels,
              spans,
          ) = dataset[i]
  
          # do not store masks as they are just arrays of 1
          content = {
              "input_ids": input_ids,
              "input_mask": input_mask,
              "segment_ids": segment_ids,
              "input_ids_for_subwords": input_ids_for_subwords,
              "input_mask_for_subwords": input_mask_for_subwords,
              "segment_ids_for_subwords": segment_ids_for_subwords,
              "character_pos_to_subword_pos": character_pos_to_subword_pos,
              "labels_mask": labels_mask,
              "labels": labels,
              "spans": spans,
          }
          b = BytesIO()
          pickle.dump(content, b)
          b.seek(0)
          tarinfo = tarfile.TarInfo(name="example_" + str(i) + ".pkl")
          tarinfo.size = b.getbuffer().nbytes
          archive.addfile(tarinfo=tarinfo, fileobj=b)
  
      archive.close()
      logging.info("Tar file " + cfg.output_tar_file + " created!")
  
imports: import pickle
  import tarfile
  from io import BytesIO
  from helpers import MODEL, instantiate_model_and_trainer
  from omegaconf import DictConfig, OmegaConf
  from nemo.core.config import hydra_runner
  from nemo.utils import logging
label_desc: Use image node_id 1 for calling a global function with example usage: main(cfg) without return types