code: def _get_state_dict(optimizer) -> dict:
      """
      Helper to get the state dict for either a raw optimizer or an optimizer
      wrapped in an LRScheduler.
      """
      if is_scheduler(optimizer):
          state = {
              "scheduler": optimizer.state_dict(),
              "optimizer": optimizer.optimizer.state_dict(),
          }
      else:
          state = optimizer.state_dict()
      return state
  
imports: import inspect
  from typing import Any, Callable, Dict, Iterable, List, Optional, Type, Union, ValuesView
  import torch
  from torch import Tensor
  from torch.nn.utils import clip_grad_norm_, clip_grad_value_
  from torch.optim import Optimizer
  import pyro
  from pyro.optim.adagrad_rmsprop import AdagradRMSProp
  from pyro.optim.clipped_adam import ClippedAdam
  from pyro.optim.dct_adam import DCTAdam
  from pyro.params.param_store import module_from_param_with_module_name, normalize_param_name, user_param_name
label_desc: Use image node_id 2 for calling a global function with example usage: _get_state_dict(optimizer) and returns: state