code: def _get_trapz2d_mult_kernel(use_double, use_complex):
      template = Template(
          """
      #include <pycuda-complex.hpp>
  
      #if ${use_double}
      #if ${use_complex}
      #define TYPE pycuda::complex<double>
      #else
      #define TYPE double
      #endif
      #else
      #if ${use_complex}
      #define TYPE pycuda::complex<float>
      #else
      #define TYPE float
      #endif
      #endif
  
      // Ny: number of rows
      // Nx: number of columns
      __global__ void gen_trapz2d_mult(TYPE *mult,
                                       unsigned int Ny, unsigned int Nx) {
          unsigned int idx = blockIdx.y*blockDim.x*gridDim.x+
                             blockIdx.x*blockDim.x+threadIdx.x;
  
          if (idx < Nx*Ny) {
              if (idx == 0 || idx == Nx-1 || idx == Nx*(Ny-1) || idx == Nx*Ny-1)
                  mult[idx] = TYPE(0.25);
              else if ((idx > 0 && idx < Nx-1) || (idx % Nx == 0) ||
                      (((idx + 1) % Nx) == 0) || (idx > Nx*(Ny-1) && idx < Nx*Ny-1))
                  mult[idx] = TYPE(0.5);
              else
                  mult[idx] = TYPE(1.0);
          }
      }
      """
      )
  
      # Set this to False when debugging to make sure the compiled kernel is
      # not cached:
      tmpl = template.substitute(
          use_double=use_double, use_complex=use_complex
      )
      cache_dir = None
      mod = SourceModule(tmpl, cache_dir=cache_dir)
      return mod.get_function("gen_trapz2d_mult")
  
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 5 for calling a global function with example usage: _get_trapz2d_mult_kernel(use_double, use_complex) and returns: mod