code: def get_take_put_kernel(dtype, idx_dtype, with_offsets, vec_count=1):
      ctx = {
          "idx_tp": dtype_to_ctype(idx_dtype),
          "tp": dtype_to_ctype(dtype),
          "tex_tp": dtype_to_ctype(dtype, with_fp_tex_hack=True),
      }
  
      args = (
          [
              VectorArg(idx_dtype, "gmem_dest_idx"),
              VectorArg(idx_dtype, "gmem_src_idx"),
          ]
          + [VectorArg(dtype, "dest%d" % i) for i in range(vec_count)]
          + [
              ScalarArg(idx_dtype, "offset%d" % i)
              for i in range(vec_count)
              if with_offsets
          ]
          + [ScalarArg(np.intp, "n")]
      )
  
      preamble = "#include <pycuda-helpers.hpp>\n\n" + "\n".join(
          "texture <%s, 1, cudaReadModeElementType> tex_src%d;"
          % (ctx["tex_tp"], i)
          for i in range(vec_count)
      )
  
      if with_offsets:
  
          def get_copy_insn(i):
              return (
                  "dest%d[dest_idx] = "
                  "fp_tex1Dfetch(tex_src%d, src_idx+offset%d);"
                  % (i, i, i)
              )
  
      else:
  
          def get_copy_insn(i):
              return (
                  "dest%d[dest_idx] = "
                  "fp_tex1Dfetch(tex_src%d, src_idx);" % (i, i)
              )
  
      body = (
          "%(idx_tp)s src_idx = gmem_src_idx[i];\n"
          "%(idx_tp)s dest_idx = gmem_dest_idx[i];\n" % ctx
      ) + "\n".join(get_copy_insn(i) for i in range(vec_count))
  
      mod = get_elwise_module(args, body, "take_put", preamble=preamble)
      func = mod.get_function("take_put")
      tex_src = [
          mod.get_texref("tex_src%d" % i) for i in range(vec_count)
      ]
  
      func.prepare(
          "PP"
          + (vec_count * "P")
          + (bool(with_offsets) * vec_count * idx_dtype.char)
          + np.dtype(np.uintp).char,
          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 6 for calling a global function with example usage: get_take_put_kernel(dtype, idx_dtype, with_offsets, vec_count) and returns: func,  tex_src, unknown, unknown