code: def get_args_parser(add_help=True):
      import argparse
  
      parser = argparse.ArgumentParser(
          description="PyTorch Stereo Matching Training",
          add_help=add_help,
      )
      # checkpointing
      parser.add_argument(
          "--name", default="crestereo", help="name of the experiment"
      )
      parser.add_argument(
          "--resume",
          type=str,
          default=None,
          help="from which checkpoint to resume",
      )
      parser.add_argument(
          "--checkpoint-dir",
          type=str,
          default="checkpoints",
          help="path to the checkpoint directory",
      )
  
      # dataset
      parser.add_argument(
          "--dataset-root",
          type=str,
          default="",
          help="path to the dataset root directory",
      )
      parser.add_argument(
          "--train-datasets",
          type=str,
          nargs="+",
          default=["crestereo"],
          help="dataset(s) to train on",
          choices=list(VALID_DATASETS.keys()),
      )
      parser.add_argument(
          "--dataset-steps",
          type=int,
          nargs="+",
          default=[300_000],
          help="number of steps for each dataset",
      )
      parser.add_argument(
          "--steps-is-epochs",
          action="store_true",
          help="if set, dataset-steps are interpreted as epochs",
      )
      parser.add_argument(
          "--test-datasets",
          type=str,
          nargs="+",
          default=["middlebury2014-train"],
          help="dataset(s) to test on",
          choices=["middlebury2014-train"],
      )
      parser.add_argument(
          "--dataset-shuffle",
          type=bool,
          help="shuffle the dataset",
          default=True,
      )
      parser.add_argument(
          "--dataset-order-shuffle",
          type=bool,
          help="shuffle the dataset order",
          default=True,
      )
      parser.add_argument(
          "--batch-size", type=int, default=2, help="batch size per GPU"
      )
      parser.add_argument(
          "--workers",
          type=int,
          default=4,
          help="number of workers per GPU",
      )
      parser.add_argument(
          "--threads",
          type=int,
          default=16,
          help="number of CPU threads per GPU. This can be changed around to speed-up transforms if needed. This can lead to worker thread contention so use with care.",
      )
  
      # model architecture
      parser.add_argument(
          "--model",
          type=str,
          default="crestereo_base",
          help="model architecture",
          choices=["crestereo_base", "raft_stereo"],
      )
      parser.add_argument(
          "--recurrent-updates",
          type=int,
          default=10,
          help="number of recurrent updates",
      )
      parser.add_argument(
          "--freeze-batch-norm",
          action="store_true",
          help="freeze batch norm parameters",
      )
  
      # loss parameters
      parser.add_argument(
          "--gamma",
          type=float,
          default=0.8,
          help="gamma parameter for the flow sequence loss",
      )
      parser.add_argument(
          "--flow-loss-weight",
          type=float,
          default=1.0,
          help="weight for the flow loss",
      )
      parser.add_argument(
          "--flow-loss-exclude-large",
          action="store_true",
          help="exclude large flow values from the loss. A large value is defined as a value greater than the ground truth flow norm",
          default=False,
      )
      parser.add_argument(
          "--consistency-weight",
          type=float,
          default=0.0,
          help="consistency loss weight",
      )
      parser.add_argument(
          "--consistency-resize-factor",
          type=float,
          default=0.25,
          help="consistency loss resize factor to account for the fact that the flow is computed on a downsampled image",
      )
      parser.add_argument(
          "--psnr-weight",
          type=float,
          default=0.0,
          help="psnr loss weight",
      )
      parser.add_argument(
          "--smoothness-weight",
          type=float,
          default=0.0,
          help="smoothness loss weight",
      )
      parser.add_argument(
          "--photometric-weight",
          type=float,
          default=0.0,
          help="photometric loss weight",
      )
      parser.add_argument(
          "--photometric-max-displacement-ratio",
          type=float,
          default=0.15,
          help="Only pixels with a displacement smaller than this ratio of the image width will be considered for the photometric loss",
      )
      parser.add_argument(
          "--photometric-ssim-weight",
          type=float,
          default=0.85,
          help="photometric ssim loss weight",
      )
  
      # transforms parameters
      parser.add_argument(
          "--gpu-transforms",
          action="store_true",
          help="use GPU transforms",
      )
      parser.add_argument(
          "--eval-size",
          type=int,
          nargs="+",
          default=[384, 512],
          help="size of the images for evaluation",
      )
      parser.add_argument(
          "--resize-size",
          type=int,
          nargs=2,
          default=None,
          help="resize size",
      )
      parser.add_argument(
          "--crop-size",
          type=int,
          nargs=2,
          default=[384, 512],
          help="crop size",
      )
      parser.add_argument(
          "--scale-range",
          type=float,
          nargs=2,
          default=[0.6, 1.0],
          help="random scale range",
      )
      parser.add_argument(
          "--rescale-prob",
          type=float,
          default=1.0,
          help="probability of resizing the image",
      )
      parser.add_argument(
          "--scaling-type",
          type=str,
          default="linear",
          help="scaling type",
          choices=["exponential", "linear"],
      )
      parser.add_argument(
          "--flip-prob",
          type=float,
          default=0.5,
          help="probability of flipping the image",
      )
      parser.add_argument(
          "--norm-mean",
          type=float,
          nargs="+",
          default=[0.5, 0.5, 0.5],
          help="mean for image normalization",
      )
      parser.add_argument(
          "--norm-std",
          type=float,
          nargs="+",
          default=[0.5, 0.5, 0.5],
          help="std for image normalization",
      )
      parser.add_argument(
          "--use-grayscale",
          action="store_true",
          help="use grayscale images instead of RGB",
          default=False,
      )
      parser.add_argument(
          "--max-disparity",
          type=float,
          default=None,
          help="maximum disparity",
      )
      parser.add_argument(
          "--interpolation-strategy",
          type=str,
          default="bilinear",
          help="interpolation strategy",
          choices=["bilinear", "bicubic", "mixed"],
      )
      parser.add_argument(
          "--spatial-shift-prob",
          type=float,
          default=1.0,
          help="probability of shifting the image",
      )
      parser.add_argument(
          "--spatial-shift-max-angle",
          type=float,
          default=0.1,
          help="maximum angle for the spatial shift",
      )
      parser.add_argument(
          "--spatial-shift-max-displacement",
          type=float,
          default=2.0,
          help="maximum displacement for the spatial shift",
      )
      parser.add_argument(
          "--gamma-range",
          type=float,
          nargs="+",
          default=[0.8, 1.2],
          help="range for gamma correction",
      )
      parser.add_argument(
          "--brightness-range",
          type=float,
          nargs="+",
          default=[0.8, 1.2],
          help="range for brightness correction",
      )
      parser.add_argument(
          "--contrast-range",
          type=float,
          nargs="+",
          default=[0.8, 1.2],
          help="range for contrast correction",
      )
      parser.add_argument(
          "--saturation-range",
          type=float,
          nargs="+",
          default=0.0,
          help="range for saturation correction",
      )
      parser.add_argument(
          "--hue-range",
          type=float,
          nargs="+",
          default=0.0,
          help="range for hue correction",
      )
      parser.add_argument(
          "--asymmetric-jitter-prob",
          type=float,
          default=1.0,
          help="probability of using asymmetric jitter instead of symmetric jitter",
      )
      parser.add_argument(
          "--occlusion-prob",
          type=float,
          default=0.5,
          help="probability of occluding the rightimage",
      )
      parser.add_argument(
          "--occlusion-px-range",
          type=int,
          nargs="+",
          default=[50, 100],
          help="range for the number of occluded pixels",
      )
      parser.add_argument(
          "--erase-prob",
          type=float,
          default=0.0,
          help="probability of erasing in both images",
      )
      parser.add_argument(
          "--erase-px-range",
          type=int,
          nargs="+",
          default=[50, 100],
          help="range for the number of erased pixels",
      )
      parser.add_argument(
          "--erase-num-repeats",
          type=int,
          default=1,
          help="number of times to repeat the erase operation",
      )
  
      # optimizer parameters
      parser.add_argument(
          "--optimizer",
          type=str,
          default="adam",
          help="optimizer",
          choices=["adam", "sgd"],
      )
      parser.add_argument(
          "--lr", type=float, default=4e-4, help="learning rate"
      )
      parser.add_argument(
          "--weight-decay", type=float, default=0.0, help="weight decay"
      )
      parser.add_argument(
          "--clip-grad-norm",
          type=float,
          default=0.0,
          help="clip grad norm",
      )
  
      # lr_scheduler parameters
      parser.add_argument(
          "--min-lr",
          type=float,
          default=2e-5,
          help="minimum learning rate",
      )
      parser.add_argument(
          "--warmup-steps",
          type=int,
          default=6_000,
          help="number of warmup steps",
      )
      parser.add_argument(
          "--decay-after-steps",
          type=int,
          default=180_000,
          help="number of steps after which to start decay the lr",
      )
      parser.add_argument(
          "--lr-warmup-method",
          type=str,
          default="linear",
          help="warmup method",
          choices=["linear", "cosine"],
      )
      parser.add_argument(
          "--lr-warmup-factor",
          type=float,
          default=0.02,
          help="warmup factor for the learning rate",
      )
      parser.add_argument(
          "--lr-decay-method",
          type=str,
          default="linear",
          help="decay method",
          choices=["linear", "cosine", "exponential"],
      )
      parser.add_argument(
          "--lr-decay-gamma",
          type=float,
          default=0.8,
          help="decay factor for the learning rate",
      )
  
      # deterministic behaviour
      parser.add_argument(
          "--seed",
          type=int,
          default=42,
          help="seed for random number generators",
      )
  
      # mixed precision training
      parser.add_argument(
          "--mixed-precision",
          action="store_true",
          help="use mixed precision training",
      )
  
      # logging
      parser.add_argument(
          "--tensorboard-summaries",
          action="store_true",
          help="log to tensorboard",
      )
      parser.add_argument(
          "--tensorboard-log-frequency",
          type=int,
          default=100,
          help="log frequency",
      )
      parser.add_argument(
          "--save-frequency",
          type=int,
          default=1_000,
          help="save frequency",
      )
      parser.add_argument(
          "--valid-frequency",
          type=int,
          default=1_000,
          help="validation frequency",
      )
      parser.add_argument(
          "--metrics",
          type=str,
          nargs="+",
          default=["mae", "rmse", "1px", "3px", "5px", "relepe"],
          help="metrics to log",
          choices=AVAILABLE_METRICS,
      )
  
      # distributed parameters
      parser.add_argument(
          "--world-size",
          type=int,
          default=8,
          help="number of distributed processes",
      )
      parser.add_argument(
          "--dist-url",
          type=str,
          default="env://",
          help="url used to set up distributed training",
      )
      parser.add_argument(
          "--device",
          type=str,
          default="cuda",
          help="device to use for training",
      )
  
      # weights API
      parser.add_argument(
          "--weights", type=str, default=None, help="weights API url"
      )
      parser.add_argument(
          "--resume-path",
          type=str,
          default=None,
          help="a path from which to resume or start fine-tuning",
      )
      parser.add_argument(
          "--resume-schedule",
          action="store_true",
          help="resume optimizer state",
      )
  
      # padder parameters
      parser.add_argument(
          "--padder-type",
          type=str,
          default="kitti",
          help="padder type",
          choices=["kitti", "sintel"],
      )
      return parser
  
imports: import argparse
  import os
  import warnings
  from pathlib import Path
  from typing import List, Union
  import numpy
  import torch
  import torch.distributed
  import torchvision.models.optical_flow
  import torchvision.prototype.models.depth.stereo
  import utils
  import visualization
  from parsing import make_dataset, make_eval_transform, make_train_transform, VALID_DATASETS
  from torch import nn
  from torchvision.transforms.functional import get_dimensions, InterpolationMode, resize
  from utils.metrics import AVAILABLE_METRICS
  from utils.norm import freeze_batch_norm
label_desc: Use image node_id 11 for calling a global function with example usage: get_args_parser(add_help) and returns: parser