code: def affine_from_pending(pending_item):
      """Extract the affine matrix from a pending transform item."""
      if isinstance(pending_item, (torch.Tensor, np.ndarray)):
          return pending_item
      if isinstance(pending_item, dict):
          return pending_item[LazyAttr.AFFINE]
      return pending_item
  
imports: from __future__ import annotations
  import warnings
  import numpy
  import torch
  import monai
  from monai.config import NdarrayOrTensor
  from monai.data.utils import AFFINE_TOL
  from monai.transforms.utils_pytorch_numpy_unification import allclose
  from monai.utils import LazyAttr, convert_to_numpy, convert_to_tensor, look_up_option
label_desc: Use image node_id 2 for calling a global function with example usage: affine_from_pending(pending_item) and returns: pending_item, pending_item, pending_item