code: def trapz2d(x_gpu, dx=1.0, dy=1.0, handle=None):
      """
      2D trapezoidal integration.
  
      Parameters
      ----------
      x_gpu : pycuda.gpuarray.GPUArray
          Input matrix to integrate.
      dx : float
          X-axis spacing.
      dy : float
          Y-axis spacing
      handle : int
          CUBLAS context. If no context is specified, the default handle from
          `skcuda.misc._global_cublas_handle` is used.
  
      Returns
      -------
      result : float
          Definite double integral as approximated by the trapezoidal rule.
  
      Examples
      --------
      >>> import pycuda.autoinit
      >>> import pycuda.gpuarray
      >>> import numpy as np
      >>> import integrate
      >>> integrate.init()
      >>> x = np.asarray(np.random.rand(10, 10), np.float32)
      >>> x_gpu = gpuarray.to_gpu(x)
      >>> z = integrate.trapz2d(x_gpu)
      >>> np.allclose(np.trapz(np.trapz(x)), z)
      True
      """
  
      if handle is None:
          handle = misc._global_cublas_handle
  
      if len(x_gpu.shape) != 2:
          raise ValueError("input array must be 2D")
      if np.iscomplex(dx) or np.iscomplex(dy):
          raise ValueError("dx and dy must be real")
  
      float_type = x_gpu.dtype.type
      if float_type == np.complex64:
          cublas_func = cublas.cublasCdotu
      elif float_type == np.float32:
          cublas_func = cublas.cublasSdot
      elif float_type == np.complex128:
          cublas_func = cublas.cublasZdotu
      elif float_type == np.float64:
          cublas_func = cublas.cublasDdot
      else:
          raise ValueError("unsupported input type")
  
      trapz_mult_gpu = gen_trapz2d_mult(x_gpu.shape, float_type)
      result = cublas_func(
          handle,
          x_gpu.size,
          x_gpu.gpudata,
          1,
          trapz_mult_gpu.gpudata,
          1,
      )
  
      return float_type(dx) * float_type(dy) * result
  
file_path: scikit-cuda/skcuda/integrate.py
imports: from string import Template
  from pycuda.tools import context_dependent_memoize
  from pycuda.compiler import SourceModule
  import pycuda.elementwise
  import pycuda.gpuarray
  import pycuda.tools
  import numpy
  from .misc import init, shutdown
  from .None import cublas
  from .None import misc
label_desc: Use image node_id 7 for calling a global function with example usage: trapz2d(x_gpu, dx, dy, handle) and returns: unknown