code: def dot_diag(d_gpu, a_gpu, trans="N", overwrite=False, handle=None):
      """
      Dot product of diagonal and non-diagonal arrays.
  
      Computes the matrix product of a diagonal array represented as a
      vector and a non-diagonal array.
  
      Parameters
      ----------
      d_gpu : pycuda.gpuarray.GPUArray
          Array of length `N` corresponding to the diagonal of the
          multiplier.
      a_gpu : pycuda.gpuarray.GPUArray
          Multiplicand array with shape `(N, M)`. Must have same data type
          as `d_gpu`.
      trans : char
          If 'T', compute the product of the transpose of `a_gpu`.
      overwrite : bool (default: False)
          If true, save the result in `a_gpu`.
      handle : int
          CUBLAS context. If no context is specified, the default handle from
          `skcuda.misc._global_cublas_handle` is used.
  
      Returns
      -------
      r_gpu : pycuda.gpuarray.GPUArray
          The computed matrix product.
  
      Examples
      --------
      >>> import pycuda.autoinit
      >>> import pycuda.gpuarray as gpuarray
      >>> import numpy as np
      >>> import skcuda.linalg as linalg
      >>> linalg.init()
      >>> d = np.random.rand(4)
      >>> a = np.random.rand(4, 4)
      >>> d_gpu = gpuarray.to_gpu(d)
      >>> a_gpu = gpuarray.to_gpu(a)
      >>> r_gpu = linalg.dot_diag(d_gpu, a_gpu)
      >>> np.allclose(np.dot(np.diag(d), a), r_gpu.get())
      True
      """
  
      if handle is None:
          handle = misc._global_cublas_handle
  
      if not (
          len(d_gpu.shape) == 1
          or (d_gpu.shape[0] == 1 or d_gpu.shape[1] == 1)
      ):
          raise ValueError("d_gpu must be a vector")
      if len(a_gpu.shape) != 2:
          raise ValueError("a_gpu must be a matrix")
  
      trans = trans.lower()
      if trans == "n":
          rows, cols = a_gpu.shape
      else:
          cols, rows = a_gpu.shape
  
      N = d_gpu.size
      if N != rows:
          raise ValueError("incompatible dimensions")
  
      if a_gpu.dtype != d_gpu.dtype:
          raise ValueError("argument types must be the same")
  
      if a_gpu.dtype == np.complex64:
          cublas_func = cublas.cublasCdgmm
      elif a_gpu.dtype == np.float32:
          cublas_func = cublas.cublasSdgmm
      elif a_gpu.dtype == np.complex128:
          cublas_func = cublas.cublasZdgmm
      elif a_gpu.dtype == np.float64:
          cublas_func = cublas.cublasDdgmm
      else:
          raise ValueError("unsupported input type")
  
      if overwrite:
          r_gpu = a_gpu
      else:
          r_gpu = a_gpu.copy()
  
      if (trans == "n" and a_gpu.flags.c_contiguous) or (
          trans == "t" and a_gpu.flags.f_contiguous
      ):
          side = "R"
      else:
          side = "L"
  
      lda = (
          a_gpu.shape[1] if a_gpu.flags.c_contiguous else a_gpu.shape[0]
      )
      ldr = lda
  
      n, m = (
          a_gpu.shape
          if a_gpu.flags.f_contiguous
          else (a_gpu.shape[1], a_gpu.shape[0])
      )
      cublas_func(
          handle,
          side,
          n,
          m,
          a_gpu.gpudata,
          lda,
          d_gpu.gpudata,
          1,
          r_gpu.gpudata,
          ldr,
      )
      return r_gpu
  
imports: from __future__ import absolute_import, division
  from pprint import pprint
  from string import Template
  from pycuda.tools import context_dependent_memoize
  from pycuda.compiler import SourceModule
  from pycuda.reduction import ReductionKernel
  from pycuda import cumath
  import pycuda.gpuarray
  import pycuda.driver
  import pycuda.elementwise
  import pycuda.tools
  import numpy
  from .None import cublas
  from .None import cudart
  from .None import misc
  from .None import cusolver
  import sys
  from .misc import init, shutdown, add_matvec, div_matvec, mult_matvec
  from .None import install_headers
label_desc: Use image node_id 8 for calling a global function with example usage: dot_diag(d_gpu, a_gpu, trans, overwrite, handle) and returns: r_gpu