code: def do_training(args):
      prepare_output_path(args.output_dir, args.overwrite_output_dir)
      device, n_gpus = setup_backend(args.no_cuda)
      # Set seed
      args.seed = set_seed(args.seed, n_gpus)
      # prepare data
      processor = TokenClsProcessor(
          args.data_dir,
          tag_col=args.tag_col,
          ignore_token=args.ignore_token,
      )
      train_ex = processor.get_train_examples(
          filename=args.train_filename
      )
      dev_ex = processor.get_dev_examples(filename=args.dev_filename)
      test_ex = processor.get_test_examples(filename=args.test_filename)
      vocab = processor.get_vocabulary(train_ex + dev_ex + test_ex)
      vocab_size = len(vocab) + 1
      num_labels = len(processor.get_labels()) + 1
      # create an embedder
      embedder_cls = MODEL_TYPE[args.model_type]
      if args.config_file is not None:
          embedder_model = embedder_cls.from_config(
              vocab_size, num_labels, args.config_file
          )
      else:
          embedder_model = embedder_cls(vocab_size, num_labels)
  
      # load external word embeddings if present
      if args.embedding_file is not None:
          emb_dict = load_embedding_file(
              args.embedding_file, dim=embedder_model.word_embedding_dim
          )
          emb_mat = get_embedding_matrix(emb_dict, vocab)
          emb_mat = torch.tensor(emb_mat, dtype=torch.float)
          embedder_model.load_embeddings(emb_mat)
  
      classifier = NeuralTagger(
          embedder_model,
          word_vocab=vocab,
          labels=processor.get_labels(),
          use_crf=args.use_crf,
          device=device,
          n_gpus=n_gpus,
      )
  
      train_batch_size = args.b * max(1, n_gpus)
  
      train_dataset = classifier.convert_to_tensors(
          train_ex,
          max_seq_length=args.max_sentence_length,
          max_word_length=args.max_word_length,
      )
      train_sampler = RandomSampler(train_dataset)
      train_dl = DataLoader(
          train_dataset,
          sampler=train_sampler,
          batch_size=train_batch_size,
      )
      if dev_ex is not None:
          dev_dataset = classifier.convert_to_tensors(
              dev_ex,
              max_seq_length=args.max_sentence_length,
              max_word_length=args.max_word_length,
          )
          dev_sampler = SequentialSampler(dev_dataset)
          dev_dl = DataLoader(
              dev_dataset, sampler=dev_sampler, batch_size=args.b
          )
  
      if test_ex is not None:
          test_dataset = classifier.convert_to_tensors(
              test_ex,
              max_seq_length=args.max_sentence_length,
              max_word_length=args.max_word_length,
          )
          test_sampler = SequentialSampler(test_dataset)
          test_dl = DataLoader(
              test_dataset, sampler=test_sampler, batch_size=args.b
          )
      if args.lr is not None:
          opt = classifier.get_optimizer(lr=args.lr)
      classifier.train(
          train_dl,
          dev_dl,
          test_dl,
          epochs=args.e,
          batch_size=args.b,
          logging_steps=args.logging_steps,
          save_steps=args.save_steps,
          save_path=args.output_dir,
          optimizer=opt if opt is not None else None,
          best_result_file=args.best_result_file,
          word_dropout=args.word_dropout,
      )
      classifier.save_model(args.output_dir)
  
imports: import argparse
  import io
  import os
  import torch
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
  from nlp_architect.data.sequential_tagging import TokenClsInputExample, TokenClsProcessor
  from nlp_architect.data.utils import write_column_tagged_file
  from nlp_architect.models.tagging import NeuralTagger
  from nlp_architect.nn.torch.modules.embedders import IDCNN, CNNLSTM
  from nlp_architect.nn.torch import setup_backend, set_seed
  from nlp_architect.nn.torch.distillation import TeacherStudentDistill
  from nlp_architect.procedures.procedure import Procedure
  from nlp_architect.procedures.registry import register_train_cmd, register_inference_cmd
  from nlp_architect.utils.embedding import get_embedding_matrix, load_embedding_file
  from nlp_architect.utils.io import prepare_output_path
  from nlp_architect.utils.text import SpacyInstance
  from nlp_architect.nn.torch.data.dataset import ParallelDataset, ConcatTensorDataset, CombinedTensorDataset
  from nlp_architect.models.transformers import TransformerTokenClassifier
label_desc: Use image node_id 2 for calling a global function with example usage: do_training(args) without return types