code: def _check_affine_equality(img1, img2):
      """Validate affines of 2 images.
  
      Parameters
      ----------
      img1 : Niimg-like object
          See :ref:`extracting_data`.
          Image to extract the data from.
  
      img2 : Niimg-like object, optional
          See :ref:`extracting_data`.
          Contains map or mask.
  
      """
      if (
          img1.affine.shape != img2.affine.shape
          or abs(img1.affine - img2.affine).max() > INF
      ):
          raise ValueError("Images have different affine matrices.")
  
file_path: nilearn/nilearn/regions/signal_extraction.py
imports: import warnings
  import numpy
  from nibabel import Nifti1Image
  from scipy import linalg, ndimage
  from ..None import _utils, masking
  from .._utils.niimg import safe_get_data
  from ..image import new_img_like
label_desc: Use image node_id 2 for calling a global function with example usage: _check_affine_equality(img1, img2) without return types