code: def equivalent(mapping1, mapping2):
      """
      A test to see if mapping1 is equal
      to mapping2 after possibly reordering the
      domain and range of mapping.
  
      Parameters
      ----------
      mapping1 : CoordinateMap or AffineTransform
      mapping2 : CoordinateMap or AffineTransform
  
      Returns
      -------
      are_they_equal : bool
  
      Examples
      --------
      >>> ijk = CoordinateSystem('ijk')
      >>> xyz = CoordinateSystem('xyz')
      >>> T = np.random.standard_normal((4,4))
      >>> T[-1] = [0,0,0,1] # otherwise AffineTransform raises
      ...                   # an exception because
      ...                   # it's supposed to represent an
      ...                   # affine transform in homogeneous
      ...                   # coordinates
      >>> A = AffineTransform(ijk, xyz, T)
      >>> B = A.reordered_domain('ikj').reordered_range('xzy')
      >>> C = B.renamed_domain({'i':'slice'})
      >>> equivalent(A, B)
      True
      >>> equivalent(A, C)
      False
      >>> equivalent(B, C)
      False
      >>>
      >>> D = CoordinateMap(ijk, xyz, np.exp)
      >>> equivalent(D, D)
      True
      >>> E = D.reordered_domain('kij').reordered_range('xzy')
      >>> # no non-AffineTransform will ever be
      >>> # equivalent to a reordered version of itself,
      >>> # because their functions don't evaluate as equal
      >>> equivalent(D, E)
      False
      >>> equivalent(E, E)
      True
      >>>
      >>> # This has not changed the order
      >>> # of the axes, so the function is still the same
      >>>
      >>> F = D.reordered_range('xyz').reordered_domain('ijk')
      >>> equivalent(F, D)
      True
      >>> id(F) == id(D)
      False
      """
      target_dnames = mapping2.function_domain.coord_names
      target_rnames = mapping2.function_range.coord_names
  
      try:
          mapping1 = mapping1.reordered_domain(
              target_dnames
          ).reordered_range(target_rnames)
      except ValueError:
          # impossible to rename the domain and ranges of mapping1 to match mapping2
          return False
  
      return mapping1 == mapping2
  
imports: import warnings
  import numpy
  import numpy.linalg
  from nibabel import io_orientation
  from nibabel.affines import from_matvec, to_matvec
  from .coordinate_system import CoordinateSystem, is_coordsys, safe_dtype
  from .coordinate_system import product
label_desc: Use image node_id 9 for calling a global function with example usage: equivalent(mapping1, mapping2) and returns: unknown, False