code: def _validate_optimizer_input(optimizer):
      dir_optim = dir(optim)
      opts = [o.lower() for o in dir_optim]
      if isinstance(optimizer, str):
          try:
              str_idx = opts.index(optimizer.lower())
          except:
              raise ValueError(
                  "Invalid optimizer string input - must match pytorch function."
              )
          return getattr(optim, dir_optim[str_idx])
      elif hasattr(optimizer, "step") and hasattr(
          optimizer, "zero_grad"
      ):
          return optimizer
      else:
          raise ValueError("Invalid optimizer input")
  
file_path: pywick/pywick/modules/_utils.py
imports: import datetime
  import warnings
  import torch.nn.functional
  import torch.optim
  from ..metrics import Metric, CategoricalAccuracy, BinaryAccuracy
  from ..initializers import GeneralInitializer
label_desc: Use image node_id 7 for calling a global function with example usage: _validate_optimizer_input(optimizer) and returns: getattr, optimizer