code: def parse_args():
      import argparse
  
      parser = argparse.ArgumentParser(
          description="DocTR training script for text recognition (PyTorch)",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
      )
  
      parser.add_argument(
          "arch", type=str, help="text-recognition model to train"
      )
      parser.add_argument(
          "--train_path",
          type=str,
          default=None,
          help="path to train data folder(s)",
      )
      parser.add_argument(
          "--val_path",
          type=str,
          default=None,
          help="path to val data folder",
      )
      parser.add_argument(
          "--train-samples",
          type=int,
          default=1000,
          help="Multiplied by the vocab length gets you the number of synthetic training samples that will be used.",
      )
      parser.add_argument(
          "--val-samples",
          type=int,
          default=20,
          help="Multiplied by the vocab length gets you the number of synthetic validation samples that will be used.",
      )
      parser.add_argument(
          "--font",
          type=str,
          default="FreeMono.ttf,FreeSans.ttf,FreeSerif.ttf",
          help="Font family to be used",
      )
      parser.add_argument(
          "--min-chars",
          type=int,
          default=1,
          help="Minimum number of characters per synthetic sample",
      )
      parser.add_argument(
          "--max-chars",
          type=int,
          default=12,
          help="Maximum number of characters per synthetic sample",
      )
      parser.add_argument(
          "--name",
          type=str,
          default=None,
          help="Name of your training experiment",
      )
      parser.add_argument(
          "--epochs",
          type=int,
          default=10,
          help="number of epochs to train the model on",
      )
      parser.add_argument(
          "-b",
          "--batch_size",
          type=int,
          default=64,
          help="batch size for training",
      )
      parser.add_argument(
          "--backend",
          default="nccl",
          type=str,
          help="Backend to use for Torch DDP",
      )
      parser.add_argument(
          "--devices",
          default=None,
          nargs="+",
          type=int,
          help="GPU devices to use for training",
      )
      parser.add_argument(
          "--input_size",
          type=int,
          default=32,
          help="input size H for the model, W = 4*H",
      )
      parser.add_argument(
          "--lr",
          type=float,
          default=0.001,
          help="learning rate for the optimizer (Adam)",
      )
      parser.add_argument(
          "--wd",
          "--weight-decay",
          default=0,
          type=float,
          help="weight decay",
          dest="weight_decay",
      )
      parser.add_argument(
          "-j",
          "--workers",
          type=int,
          default=None,
          help="number of workers used for dataloading",
      )
      parser.add_argument(
          "--resume",
          type=str,
          default=None,
          help="Path to your checkpoint",
      )
      parser.add_argument(
          "--vocab",
          type=str,
          default="french",
          help="Vocab to be used for training",
      )
      parser.add_argument(
          "--test-only",
          dest="test_only",
          action="store_true",
          help="Run the validation loop",
      )
      parser.add_argument(
          "--freeze-backbone",
          dest="freeze_backbone",
          action="store_true",
          help="freeze model backbone for fine-tuning",
      )
      parser.add_argument(
          "--show-samples",
          dest="show_samples",
          action="store_true",
          help="Display unormalized training samples",
      )
      parser.add_argument(
          "--wb",
          dest="wb",
          action="store_true",
          help="Log to Weights & Biases",
      )
      parser.add_argument(
          "--push-to-hub",
          dest="push_to_hub",
          action="store_true",
          help="Push to Huggingface Hub",
      )
      parser.add_argument(
          "--pretrained",
          dest="pretrained",
          action="store_true",
          help="Load pretrained parameters before starting the training",
      )
      parser.add_argument(
          "--sched", type=str, default="cosine", help="scheduler to use"
      )
      parser.add_argument(
          "--amp",
          dest="amp",
          help="Use Automatic Mixed Precision",
          action="store_true",
      )
      parser.add_argument(
          "--early-stop",
          action="store_true",
          help="Enable early stopping",
      )
      parser.add_argument(
          "--early-stop-epochs",
          type=int,
          default=5,
          help="Patience for early stopping",
      )
      parser.add_argument(
          "--early-stop-delta",
          type=float,
          default=0.01,
          help="Minimum Delta for early stopping",
      )
      args = parser.parse_args()
  
      return args
  
imports: import os
  import datetime
  import hashlib
  import multiprocessing
  import time
  from pathlib import Path
  import numpy
  import torch
  import torch.distributed
  import torch.multiprocessing
  import wandb
  from torch.nn.parallel import DistributedDataParallel
  from torch.optim.lr_scheduler import CosineAnnealingLR, OneCycleLR
  from torch.utils.data import DataLoader, SequentialSampler
  from torch.utils.data.distributed import DistributedSampler
  from torchvision.transforms.v2 import Compose, GaussianBlur, Normalize, RandomGrayscale, RandomPerspective, RandomPhotometricDistort
  from tqdm.auto import tqdm
  from doctr import transforms
  from doctr.datasets import VOCABS, RecognitionDataset, WordGenerator
  from doctr.models import login_to_hub, push_to_hf_hub, recognition
  from doctr.utils.metrics import TextMatch
  from utils import EarlyStopper, plot_samples
label_desc: Use image node_id 4 for calling a global function with example usage: parse_args() and returns: args