code: def get_affine(img):
      """Return affine from nibabel image
  
      Parameters
      ----------
      img : ``SpatialImage`` instance
          Instance of nibabel ``SpatialImage`` class
  
      Returns
      -------
      affine : object
          affine object from `img`
      """
      try:
          return img.affine
      except AttributeError:
          return img.get_affine()
  
imports: import nibabel
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: get_affine(img) and returns: img, img