code: def get_take_put_kernel(
      context, dtype, idx_dtype, with_offsets, vec_count=1
  ):
      idx_tp = dtype_to_ctype(idx_dtype)
  
      args = (
          [VectorArg(dtype, f"dest{i}") for i in range(vec_count)]
          + [
              VectorArg(idx_dtype, "gmem_dest_idx", with_offset=True),
              VectorArg(idx_dtype, "gmem_src_idx", with_offset=True),
          ]
          + [
              VectorArg(dtype, f"src{i}", with_offset=True)
              for i in range(vec_count)
          ]
          + [
              ScalarArg(idx_dtype, f"offset{i}")
              for i in range(vec_count)
              if with_offsets
          ]
      )
  
      if with_offsets:
  
          def get_copy_insn(i):
              return f"dest{i}[dest_idx] = src{i}[src_idx + offset{i}];"
  
      else:
  
          def get_copy_insn(i):
              return f"dest{i}[dest_idx] = src{i}[src_idx];"
  
      body = (
          f"{idx_tp} src_idx = gmem_src_idx[i];\n"
          f"{idx_tp} dest_idx = gmem_dest_idx[i];\n"
      ) + "\n".join(get_copy_insn(i) for i in range(vec_count))
  
      return get_elwise_kernel(
          context,
          args,
          body,
          preamble=dtype_to_c_struct(context.devices[0], dtype),
          name="take_put",
      )
  
imports: import enum
  from typing import Any, List, Optional, Tuple, Union
  import numpy
  import pyopencl
  from pyopencl.tools import context_dependent_memoize
  from pyopencl.tools import dtype_to_ctype, DtypedArgument, VectorArg, ScalarArg, KernelTemplateBase, dtype_to_c_struct
  from pytools import memoize_method
label_desc: Use image node_id 7 for calling a global function with example usage: get_take_put_kernel(context, dtype, idx_dtype, with_offsets, vec_count) and returns: get_elwise_kernel, str, i, str, i, str, i, str, str, i, str, i, str