code: def get_parser(**parser_kwargs):
      def str2bool(v):
          if isinstance(v, bool):
              return v
          if v.lower() in ("yes", "true", "t", "y", "1"):
              return True
          elif v.lower() in ("no", "false", "f", "n", "0"):
              return False
          else:
              raise argparse.ArgumentTypeError(
                  "Boolean value expected."
              )
  
      parser = argparse.ArgumentParser(**parser_kwargs)
      parser.add_argument(
          "-n",
          "--name",
          type=str,
          const=True,
          default="",
          nargs="?",
          help="postfix for logdir",
      )
      parser.add_argument(
          "--no_date",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,
          help="if True, skip date generation for logdir and only use naming via opt.base or opt.name (+ opt.postfix, optionally)",
      )
      parser.add_argument(
          "-r",
          "--resume",
          type=str,
          const=True,
          default="",
          nargs="?",
          help="resume from logdir or checkpoint in logdir",
      )
      parser.add_argument(
          "-b",
          "--base",
          nargs="*",
          metavar="base_config.yaml",
          help="paths to base configs. Loaded from left-to-right. "
          "Parameters can be overwritten or added with command-line options of the form `--key value`.",
          default=list(),
      )
      parser.add_argument(
          "-t",
          "--train",
          type=str2bool,
          const=True,
          default=True,
          nargs="?",
          help="train",
      )
      parser.add_argument(
          "--no-test",
          type=str2bool,
          const=True,
          default=False,
          nargs="?",
          help="disable test",
      )
      parser.add_argument(
          "-p",
          "--project",
          help="name of new or path to existing project",
      )
      parser.add_argument(
          "-d",
          "--debug",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,
          help="enable post-mortem debugging",
      )
      parser.add_argument(
          "-s",
          "--seed",
          type=int,
          default=23,
          help="seed for seed_everything",
      )
      parser.add_argument(
          "-f",
          "--postfix",
          type=str,
          default="",
          help="post-postfix for default name",
      )
      parser.add_argument(
          "--projectname",
          type=str,
          default="stablediffusion",
      )
      parser.add_argument(
          "-l",
          "--logdir",
          type=str,
          default="logs",
          help="directory for logging dat shit",
      )
      parser.add_argument(
          "--scale_lr",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,
          help="scale base-lr by ngpu * batch_size * n_accumulate",
      )
      parser.add_argument(
          "--legacy_naming",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,
          help="name run based on config file name if true, else by whole path",
      )
      parser.add_argument(
          "--enable_tf32",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,
          help="enables the TensorFloat32 format both for matmuls and cuDNN for pytorch 1.12",
      )
      parser.add_argument(
          "--startup",
          type=str,
          default=None,
          help="Startuptime from distributed script",
      )
      parser.add_argument(
          "--wandb",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,  # TODO: later default to True
          help="log to wandb",
      )
      parser.add_argument(
          "--no_base_name",
          type=str2bool,
          nargs="?",
          const=True,
          default=False,  # TODO: later default to True
          help="log to wandb",
      )
      if version.parse(torch.__version__) >= version.parse("2.0.0"):
          parser.add_argument(
              "--resume_from_checkpoint",
              type=str,
              default=None,
              help="single checkpoint file to resume from",
          )
      default_args = default_trainer_args()
      for key in default_args:
          parser.add_argument("--" + key, default=default_args[key])
      return parser
  
imports: import argparse
  import datetime
  import glob
  import inspect
  import os
  import sys
  from inspect import Parameter
  from typing import Union
  import numpy
  import pytorch_lightning
  import torch
  import torchvision
  import wandb
  from matplotlib import pyplot
  from natsort import natsorted
  from omegaconf import OmegaConf
  from packaging import version
  from PIL import Image
  from pytorch_lightning import seed_everything
  from pytorch_lightning.callbacks import Callback
  from pytorch_lightning.loggers import WandbLogger
  from pytorch_lightning.trainer import Trainer
  from pytorch_lightning.utilities import rank_zero_only
  from sgm.util import exists, instantiate_from_config, isheatmap
label_desc: Use image node_id 2 for calling a global function with example usage: get_parser() and returns: parser, v, True, False