class_docstr: Piecewise tensor product polynomial
  
  The value at point ``xp = (x', y', z', ...)`` is evaluated by first
  computing the interval indices `i` such that::
  
      x[0][i[0]] <= x' < x[0][i[0]+1]
      x[1][i[1]] <= y' < x[1][i[1]+1]
      ...
  
  and then computing::
  
      S = sum(c[k0-m0-1,...,kn-mn-1,i[0],...,i[n]]
              * (xp[0] - x[0][i[0]])**m0
              * ...
              * (xp[n] - x[n][i[n]])**mn
              for m0 in range(k[0]+1)
              ...
              for mn in range(k[n]+1))
  
  where ``k[j]`` is the degree of the polynomial in dimension j. This
  representation is the piecewise multivariate power basis.
  
  Parameters
  ----------
  c : ndarray, shape (k0, ..., kn, m0, ..., mn, ...)
      Polynomial coefficients, with polynomial order `kj` and
      `mj+1` intervals for each dimension `j`.
  x : ndim-tuple of ndarrays, shapes (mj+1,)
      Polynomial breakpoints for each dimension. These must be
      sorted in increasing order.
  extrapolate : bool, optional
      Whether to extrapolate to out-of-bounds points based on first
      and last intervals, or to return NaNs. Default: True.
  
  Attributes
  ----------
  x : tuple of ndarrays
      Breakpoints.
  c : ndarray
      Coefficients of the polynomials.
  
  See also
  --------
  PPoly : piecewise polynomials in 1D
  
  Notes
  -----
  High-order polynomials in the power basis can be numerically
  unstable.
class_docstr_tok: ["Piecewise","tensor","product","polynomial","The","value","at","point","``","xp","=","(","x","'",",","y","'",",","z","'",",","...",")","``","is","evaluated","by","first","computing","the","interval","indices","`","i","`","such","that",":",":","x","[","0","]","[","i","[","0","]","]","<","=","x","'","<","x","[","0","]","[","i","[","0","]","+1","]","x","[","1","]","[","i","[","1","]","]","<","=","y","'","<","x","[","1","]","[","i","[","1","]","+1","]","...","and","then","computing",":",":","S","=","sum","(","c","[","k0-m0-1",",","...",",","kn-mn-1",",","i","[","0","]",",","...",",","i","[","n","]","]","*","(","xp","[","0","]","-","x","[","0","]","[","i","[","0","]","]",")","*","*","m0","*","...","*","(","xp","[","n","]","-","x","[","n","]","[","i","[","n","]","]",")","*","*","mn","for","m0","in","range","(","k","[","0","]","+1",")","...","for","mn","in","range","(","k","[","n","]","+1",")",")","where","``","k","[","j","]","``","is","the","degree","of","the","polynomial","in","dimension","j",".","This","representation","is","the","piecewise","multivariate","power","basis",".","Parameters","--","--","--","--","--","c",":","ndarray",",","shape","(","k0",",","...",",","kn",",","m0",",","...",",","mn",",","...",")","Polynomial","coefficients",",","with","polynomial","order","`","kj","`","and","`","mj+1","`","intervals","for","each","dimension","`","j","`",".","x",":","ndim-tuple","of","ndarrays",",","shapes","(","mj+1",",",")","Polynomial","breakpoints","for","each","dimension",".","These","must","be","sorted","in","increasing","order",".","extrapolate",":","bool",",","optional","Whether","to","extrapolate","to","out-of-bounds","points","based","on","first","and","last","intervals",",","or","to","return","NaNs",".","Default",":","True",".","Attributes","--","--","--","--","--","x",":","tuple","of","ndarrays","Breakpoints",".","c",":","ndarray","Coefficients","of","the","polynomials",".","See","also","--","--","--","--","PPoly",":","piecewise","polynomials","in","1D","Notes","--","--","-","High-order","polynomials","in","the","power","basis","can","be","numerically","unstable","."]
docstr: Compute a definite integral over a piecewise polynomial.
  
  Parameters
  ----------
  ranges : ndim-tuple of 2-tuples float
      Sequence of lower and upper bounds for each dimension,
      ``[(a[0], b[0]), ..., (a[ndim-1], b[ndim-1])]``
  extrapolate : bool, optional
      Whether to extrapolate to out-of-bounds points based on first
      and last intervals, or to return NaNs.
  
  Returns
  -------
  ig : array_like
      Definite integral of the piecewise polynomial over
      [a[0], b[0]] x ... x [a[ndim-1], b[ndim-1]]
code: def integrate(self, ranges, extrapolate=None):
      """
      Compute a definite integral over a piecewise polynomial.
  
      Parameters
      ----------
      ranges : ndim-tuple of 2-tuples float
          Sequence of lower and upper bounds for each dimension,
          ``[(a[0], b[0]), ..., (a[ndim-1], b[ndim-1])]``
      extrapolate : bool, optional
          Whether to extrapolate to out-of-bounds points based on first
          and last intervals, or to return NaNs.
  
      Returns
      -------
      ig : array_like
          Definite integral of the piecewise polynomial over
          [a[0], b[0]] x ... x [a[ndim-1], b[ndim-1]]
      """
  
      ndim = len(self.x)
  
      if extrapolate is None:
          extrapolate = self.extrapolate
      else:
          extrapolate = bool(extrapolate)
  
      if not hasattr(ranges, "__len__") or len(ranges) != ndim:
          raise ValueError("Range not a sequence of correct length")
  
      self._ensure_c_contiguous()
  
      # Reuse 1D integration routine
      c = self.c
      for n, (a, b) in enumerate(ranges):
          swap = list(range(c.ndim))
          swap.insert(1, swap[ndim - n])
          del swap[ndim - n + 1]
  
          c = c.transpose(swap)
  
          p = PPoly.construct_fast(
              c, self.x[n], extrapolate=extrapolate
          )
          out = p.integrate(a, b, extrapolate=extrapolate)
          c = out.reshape(c.shape[2:])
  
      return c
  
imports: import math
  import cupy
  from cupy._core import internal
  from cupy._core._scalar import get_typename
  from cupy_backends.cuda.api import runtime
  from cupyx.scipy import special
  from cupyx.scipy.interpolate._bspline import BSpline, _get_dtype
  import numpy
label_desc: Use image node_id 11 for calling the NdPPoly obj's underlying member method code with example usage: obj.integrate(ranges, extrapolate) and returns: c