docstr: Transform the input image from domain to co-domain space.
  
  By default, the transformed image is sampled at a grid defined by
  `self.codomain_shape` and `self.codomain_grid2world`. If such
  information was not provided then `sampling_grid_shape` is mandatory.
  
  Parameters
  ----------
  image :  2D or 3D array
      the image to be transformed
  interpolation : string, either 'linear' or 'nearest'
      the type of interpolation to be used, either 'linear'
      (for k-linear interpolation) or 'nearest' for nearest neighbor
  image_grid2world : array, shape (dim + 1, dim + 1), optional
      the grid-to-world transform associated with `image`.
      If None (the default), then the grid-to-world transform is assumed
      to be the identity.
  sampling_grid_shape : sequence, shape (dim,), optional
      the shape of the grid where the transformed image must be sampled.
      If None (the default), then `self.codomain_shape` is used instead
      (which must have been set at initialization, otherwise an exception
      will be raised).
  sampling_grid2world : array, shape (dim + 1, dim + 1), optional
      the grid-to-world transform associated with the sampling grid
      (specified by `sampling_grid_shape`, or by default
      `self.codomain_shape`). If None (the default), then the
      grid-to-world transform is assumed to be the identity.
  resample_only : Boolean, optional
      If False (the default) the affine transform is applied normally.
      If True, then the affine transform is not applied, and the input
      image is just re-sampled on the domain grid of this transform.
  
  Returns
  -------
  transformed : array, shape `sampling_grid_shape` or
                `self.codomain_shape`
      the transformed image, sampled at the requested grid
docstr_tok: ["Transform","the","input","image","from","domain","to","co-domain","space",".","By","default",",","the","transformed","image","is","sampled","at","a","grid","defined","by","`","self.codomain_shape","`","and","`","self.codomain_grid2world","`",".","If","such","information","was","not","provided","then","`","sampling_grid_shape","`","is","mandatory",".","Parameters","--","--","--","--","--","image",":","2D","or","3D","array","the","image","to","be","transformed","interpolation",":","string",",","either","'linear","'","or","'nearest'","the","type","of","interpolation","to","be","used",",","either","'linear'","(","for","k-linear","interpolation",")","or","'nearest","'","for","nearest","neighbor","image_grid2world",":","array",",","shape","(","dim","+","1",",","dim","+","1",")",",","optional","the","grid-to-world","transform","associated","with","`","image","`",".","If","None","(","the","default",")",",","then","the","grid-to-world","transform","is","assumed","to","be","the","identity",".","sampling_grid_shape",":","sequence",",","shape","(","dim",",",")",",","optional","the","shape","of","the","grid","where","the","transformed","image","must","be","sampled",".","If","None","(","the","default",")",",","then","`","self.codomain_shape","`","is","used","instead","(","which","must","have","been","set","at","initialization",",","otherwise","an","exception","will","be","raised",")",".","sampling_grid2world",":","array",",","shape","(","dim","+","1",",","dim","+","1",")",",","optional","the","grid-to-world","transform","associated","with","the","sampling","grid","(","specified","by","`","sampling_grid_shape","`",",","or","by","default","`","self.codomain_shape","`",")",".","If","None","(","the","default",")",",","then","the","grid-to-world","transform","is","assumed","to","be","the","identity",".","resample_only",":","Boolean",",","optional","If","False","(","the","default",")","the","affine","transform","is","applied","normally",".","If","True",",","then","the","affine","transform","is","not","applied",",","and","the","input","image","is","just","re-sampled","on","the","domain","grid","of","this","transform",".","Returns","--","--","--","-","transformed",":","array",",","shape","`","sampling_grid_shape","`","or","`","self.codomain_shape","`","the","transformed","image",",","sampled","at","the","requested","grid"]
code: def transform_inverse(
      self,
      image,
      interpolation="linear",
      image_grid2world=None,
      sampling_grid_shape=None,
      sampling_grid2world=None,
      resample_only=False,
  ):
      """Transform the input image from domain to co-domain space.
  
      By default, the transformed image is sampled at a grid defined by
      `self.codomain_shape` and `self.codomain_grid2world`. If such
      information was not provided then `sampling_grid_shape` is mandatory.
  
      Parameters
      ----------
      image :  2D or 3D array
          the image to be transformed
      interpolation : string, either 'linear' or 'nearest'
          the type of interpolation to be used, either 'linear'
          (for k-linear interpolation) or 'nearest' for nearest neighbor
      image_grid2world : array, shape (dim + 1, dim + 1), optional
          the grid-to-world transform associated with `image`.
          If None (the default), then the grid-to-world transform is assumed
          to be the identity.
      sampling_grid_shape : sequence, shape (dim,), optional
          the shape of the grid where the transformed image must be sampled.
          If None (the default), then `self.codomain_shape` is used instead
          (which must have been set at initialization, otherwise an exception
          will be raised).
      sampling_grid2world : array, shape (dim + 1, dim + 1), optional
          the grid-to-world transform associated with the sampling grid
          (specified by `sampling_grid_shape`, or by default
          `self.codomain_shape`). If None (the default), then the
          grid-to-world transform is assumed to be the identity.
      resample_only : Boolean, optional
          If False (the default) the affine transform is applied normally.
          If True, then the affine transform is not applied, and the input
          image is just re-sampled on the domain grid of this transform.
  
      Returns
      -------
      transformed : array, shape `sampling_grid_shape` or
                    `self.codomain_shape`
          the transformed image, sampled at the requested grid
  
      """
      transformed = self._apply_transform(
          image,
          interpolation,
          image_grid2world,
          sampling_grid_shape,
          sampling_grid2world,
          resample_only,
          apply_inverse=True,
      )
      return np.array(transformed)
  
imports: from warnings import warn
  import numpy
  import numpy.linalg
  import scipy.ndimage
  from dipy.core.optimize import Optimizer
  from dipy.core.interpolation import interpolate_scalar_2d, interpolate_scalar_3d
  from dipy.align import vector_fields
  from dipy.align import VerbosityLevels
  from dipy.align.parzenhist import ParzenJointHistogram, sample_domain_regular, compute_parzen_mi
  from dipy.align.imwarp import get_direction_and_spacings, ScaleSpace
  from dipy.align.scalespace import IsotropicScaleSpace
  from dipy.utils.deprecator import deprecated_params
label_desc: Use image node_id 9 for calling the AffineMap obj's underlying member method code with example usage: obj.transform_inverse(image, interpolation, image_grid2world, sampling_grid_shape, sampling_grid2world, resample_only) and returns: np