code: def main():
      parser = HfArgumentParser(
          (
              ModelArguments,
              TrainingArguments,
              FlertArguments,
              DataArguments,
          )
      )
  
      if len(sys.argv) == 2 and sys.argv[1].endswith(".json"):
          (
              model_args,
              training_args,
              flert_args,
              data_args,
          ) = parser.parse_json_file(
              json_file=os.path.abspath(sys.argv[1])
          )
      else:
          (
              model_args,
              training_args,
              flert_args,
              data_args,
          ) = parser.parse_args_into_dataclasses()
  
      set_seed(training_args.seed)
  
      flair.device = training_args.device
  
      corpus = get_flair_corpus(data_args)
  
      logger.info(corpus)
  
      tag_type: str = "ner"
      tag_dictionary = corpus.make_label_dictionary(
          tag_type, add_unk=False
      )
      logger.info(tag_dictionary)
  
      embeddings = TransformerWordEmbeddings(
          model=model_args.model_name_or_path,
          layers=model_args.layers,
          subtoken_pooling=model_args.subtoken_pooling,
          fine_tune=True,
          use_context=flert_args.context_size,
          respect_document_boundaries=flert_args.respect_document_boundaries,
      )
  
      tagger = SequenceTagger(
          hidden_size=model_args.hidden_size,
          embeddings=embeddings,
          tag_dictionary=tag_dictionary,
          tag_type=tag_type,
          use_crf=model_args.use_crf,
          use_rnn=False,
          reproject_embeddings=False,
      )
  
      trainer = ModelTrainer(tagger, corpus)
  
      trainer.fine_tune(
          data_args.output_dir,
          learning_rate=training_args.learning_rate,
          mini_batch_size=training_args.batch_size,
          mini_batch_chunk_size=training_args.mini_batch_chunk_size,
          max_epochs=training_args.num_epochs,
          embeddings_storage_mode=training_args.embeddings_storage_mode,
          weight_decay=training_args.weight_decay,
      )
  
      torch.save(
          model_args,
          os.path.join(data_args.output_dir, "model_args.bin"),
      )
      torch.save(
          training_args,
          os.path.join(data_args.output_dir, "training_args.bin"),
      )
  
      # finally, print model card for information
      tagger.print_model_card()
  
file_path: flair/examples/ner/run_ner.py
imports: import inspect
  import json
  import logging
  import os
  import sys
  from dataclasses import dataclass, field
  import torch
  from transformers import HfArgumentParser
  import flair
  from flair import set_seed
  from flair.embeddings import TransformerWordEmbeddings
  from flair.models import SequenceTagger
  from flair.trainers import ModelTrainer
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types