code: def parse_args():
      import argparse
  
      parser = argparse.ArgumentParser(
          description="DocTR training script for text detection (PyTorch)",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
      )
  
      parser.add_argument(
          "train_path", type=str, help="path to training data folder"
      )
      parser.add_argument(
          "val_path", type=str, help="path to validation data folder"
      )
      parser.add_argument(
          "arch", type=str, help="text-detection model to train"
      )
      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=2,
          help="batch size for training",
      )
      parser.add_argument(
          "--device", default=None, type=int, help="device"
      )
      parser.add_argument(
          "--input_size",
          type=int,
          default=1024,
          help="model input size, H = W",
      )
      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(
          "--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(
          "--rotation",
          dest="rotation",
          action="store_true",
          help="train with rotated documents",
      )
      parser.add_argument(
          "--eval-straight",
          action="store_true",
          help="metrics evaluation with straight boxes instead of polygons to save time + memory",
      )
      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(
          "--find-lr",
          action="store_true",
          help="Gridsearch the optimal LR",
      )
      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 logging
  import multiprocessing
  import time
  import numpy
  import psutil
  import torch
  import wandb
  from torch.optim.lr_scheduler import CosineAnnealingLR, MultiplicativeLR, OneCycleLR
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
  from torchvision.transforms.v2 import Compose, GaussianBlur, Normalize, RandomGrayscale, RandomPhotometricDistort
  from tqdm.auto import tqdm
  from doctr import transforms
  from doctr.datasets import DetectionDataset
  from doctr.models import detection, login_to_hub, push_to_hf_hub
  from doctr.utils.metrics import LocalizationConfusion
  from utils import EarlyStopper, plot_recorder, plot_samples
label_desc: Use image node_id 5 for calling a global function with example usage: parse_args() and returns: args