code: def prepare_template_vals(dtype, compute_capability, rounding=False):
      """
      Set up template code snippets that are reused across multiple kernels.
      Most are data type conversion and statistics collection related.
      """
      template_vals = dict()
      for key in (
          "inits",
          "finish",
          "stats_args",
          "mul_by_scale",
          "atomic_max",
          "cvt_out",
      ):
          template_vals[key] = ""
  
      template_vals["common"] = _common_divmod
  
      if rounding:
          template_vals["common"] += _common_urand_gen
          template_vals["common"] += _common_round["nearest"].get(
              dtype, ""
          )
          template_vals["inits"] += (
              _init_rand_func + _init_rand_round_func
          )
          template_vals["finish"] += _finish_rand_func
          mode = "random"
      else:
          mode = "nearest"
  
      template_vals["common"] += _common_round[mode].get(dtype, "")
      template_vals["common"] += _common_max_abs
  
      if (
          compute_capability[0] == 3 and compute_capability[1] < 5
      ) or compute_capability[0] < 3:
          template_vals["common"] += _common_kepler
  
      template_vals["type"] = _ew_types[dtype]["type"]
      template_vals["cvt"] = _ew_types[dtype]["cvt"]
  
      if dtype == "f2":
          template_vals["common"] += _common_fp16_to_fp32
          template_vals["cvt_out"] = "fp32_to_fp16"
      elif dtype == "x2":
          template_vals["stats_args"] += ", int* maxabs, float scale0"
          template_vals["cvt"] = "(float)"
          template_vals["cvt_out"] = "fp32_to_int16"
          template_vals["mul_by_scale"] += "1/scale0 *"
          template_vals["atomic_max"] += atomic_max
      elif dtype == "f4":
          pass
      else:
          raise ValueError(
              "Did not understand clss dtype " + str(dtype)
          )
  
      return template_vals
  
file_path: neon/neon/backends/kernels/cuda/pooling.py
imports: from builtins import str
  from pycuda.tools import context_dependent_memoize
  from neon.backends import cuda_templates
  from neon.backends.cuda_templates import _common_fp16_to_fp32, _common_round, _common_max_abs, _common_kepler, _ew_types
  from neon.backends.util.source_module import SourceModule
label_desc: Use image node_id 2 for calling a global function with example usage: prepare_template_vals(dtype, compute_capability, rounding) and returns: template_vals