code: def check_required_args(args, eval_only=False):
      """
      Check that the required training arguments are present.
  
      Args:
          args (argparse object): the arguments to check
          eval_only (bool) : whether to check only the arguments for evaluation
      """
      required_args_eval = ["adv_eval"]
      required_args_train = [
          "epochs",
          "out_dir",
          "adv_train",
          "log_iters",
          "lr",
          "momentum",
          "weight_decay",
      ]
      adv_required_args = [
          "attack_steps",
          "eps",
          "constraint",
          "use_best",
          "attack_lr",
          "random_restarts",
      ]
  
      # Generic function for checking all arguments in a list
      def check_args(args_list):
          for arg in args_list:
              assert has_attr(args, arg), f"Missing argument {arg}"
  
      # Different required args based on training or eval:
      if not eval_only:
          check_args(required_args_train)
      else:
          check_args(required_args_eval)
      # More required args if we are robustly training or evaling
      is_adv = bool(args.adv_train) or bool(args.adv_eval)
      if is_adv:
          check_args(adv_required_args)
      # More required args if the user provides a custom training loss
      has_custom_train = has_attr(args, "custom_train_loss")
      has_custom_adv = has_attr(args, "custom_adv_loss")
      if has_custom_train and is_adv and not has_custom_adv:
          raise ValueError(
              "Cannot use custom train loss \
              without a custom adversarial loss (see docs)"
          )
  
file_path: robustness/robustness/train.py
imports: import torch
  import numpy
  import torch.nn
  from torch.optim import SGD, lr_scheduler
  from torchvision.utils import make_grid
  from cox.utils import Parameters
  from .tools import helpers
  from .tools.helpers import AverageMeter, ckpt_at_epoch, has_attr
  from .tools import constants
  import dill
  import os
  import time
  import warnings
label_desc: Use image node_id 1 for calling a global function with example usage: check_required_args(args, eval_only) without return types