code: def get_linear_combination_kernel(summand_descriptors, dtype_z):
      from pycuda.tools import dtype_to_ctype
      from pycuda.elementwise import (
          VectorArg,
          ScalarArg,
          get_elwise_module,
      )
  
      args = []
      preamble = ["#include <pycuda-helpers.hpp>\n\n"]
      loop_prep = []
      summands = []
      tex_names = []
  
      for i, (is_gpu_scalar, scalar_dtype, vector_dtype) in enumerate(
          summand_descriptors
      ):
          if is_gpu_scalar:
              preamble.append(
                  "texture <%s, 1, cudaReadModeElementType> tex_a%d;"
                  % (
                      dtype_to_ctype(
                          scalar_dtype, with_fp_tex_hack=True
                      ),
                      i,
                  )
              )
              args.append(VectorArg(vector_dtype, "x%d" % i))
              tex_names.append("tex_a%d" % i)
              loop_prep.append(
                  "%s a%d = fp_tex1Dfetch(tex_a%d, 0)"
                  % (dtype_to_ctype(scalar_dtype), i, i)
              )
          else:
              args.append(ScalarArg(scalar_dtype, "a%d" % i))
              args.append(VectorArg(vector_dtype, "x%d" % i))
  
          summands.append("a%d*x%d[i]" % (i, i))
  
      args.append(VectorArg(dtype_z, "z"))
      args.append(ScalarArg(np.uintp, "n"))
  
      mod = get_elwise_module(
          args,
          "z[i] = " + " + ".join(summands),
          "linear_combination",
          preamble="\n".join(preamble),
          loop_prep=";\n".join(loop_prep),
      )
  
      func = mod.get_function("linear_combination")
      tex_src = [mod.get_texref(tn) for tn in tex_names]
      func.prepare(
          "".join(arg.struct_char for arg in args), texrefs=tex_src
      )
  
      return func, tex_src
  
imports: from pycuda.tools import context_dependent_memoize
  from typing import Any
  import numpy
  from pycuda.tools import dtype_to_ctype, VectorArg, ScalarArg
  from pytools import memoize_method
label_desc: Use image node_id 9 for calling a global function with example usage: get_linear_combination_kernel(summand_descriptors, dtype_z) and returns: func,  tex_src