code: def tune_cutlass_function(
      func,
      use_3xtf32,
      split_k_slices,
      profile_all_alignments,
      find_first_valid,
      use_multiprocessing,
      gemm_profiler,
      conv2d_profiler,
  ):
      """Given a function intended to be offloaded to CUTLASS,  profile each workload to select which
      kernels to emit.
  
      Parameters
      ----------
      func : IRModule
          The Relay Function to tune for.
  
      use_3xtf32 : bool
          Wheter or not use slower but very accurate (compared to tf32) 3xtf32 mode for
          fp32 inputs on tensorcore.
  
      split_k_slices : list of int
          Split factor candidates for split-K GEMM. If split-K > 1, the GEMM K-loop is computed in
          parallel accross split-K blocks, and a seperate global reduction kernel is launched to
          accumulate partial reductions. The profiler will pick the best split-k factor from the
          given candidate list. Note that the larger split-K factor requires a larger workspace.
          Currently, parallel split-k has been tested only for wgrad. For GEMM and other conv2d
          kinds, split_k_slices is ignored.
  
      profile_all_alignments : bool
          When True, profile all kernal variants with smaller alignments than the largest possible.
  
      find_first_valid : bool
          Whether or not profile all candidate kernels, or stop profiling after
          the first applicable kernel is found.
  
      use_multiprocessing : bool
          Whether or not compile profiler executables for different kernels in parallel.
  
      gemm_profiler : CutlassGemmProfiler
          Profiler for dense operators. May cache results between tuned functions.
  
      conv2d_profiler : CutlassConv2DProfiler
          Profiler for conv2d operators. May cach results between tuned functions.
  
      Returns
      -------
      annot_func : Function
          The input function with attributes capturing the best CUTLASS kernel found by tuning.
      """
      annotator = OpAnnotator()
      annotator.visit(func)
      out_shape = annotator.signature["ret_shape"]
      out_dtype = annotator.signature["ret_dtype"]
      op_type = annotator.signature["op_type"]
  
      new_attrs = {"op_type": op_type}
      new_attrs.update(annotator.signature)
      new_attrs.update(func.attrs)
      arg0_shape = new_attrs["arg0_shape"]
      arg1_shape = new_attrs["arg1_shape"]
      arg0_dtype = new_attrs["arg0_dtype"]
      arg1_dtype = new_attrs["arg1_dtype"]
  
      if "conv2d" in op_type:
          new_attrs["padding"] = annotator.op_attrs.padding
          new_attrs["strides"] = annotator.op_attrs.strides
          new_attrs["dilation"] = annotator.op_attrs.dilation
  
          if "conv2d_transpose" in op_type:
              d_shape = out_shape
              w_shape = arg1_shape
          elif "conv2d_backward_weight" in op_type:
              d_shape = arg1_shape
              w_shape = out_shape
          else:
              d_shape = arg0_shape
              w_shape = arg1_shape
  
          new_attrs.update(
              handle_conv2d(
                  conv2d_profiler,
                  op_type,
                  d_shape,
                  w_shape,
                  annotator.op_attrs.padding,
                  annotator.op_attrs.strides,
                  annotator.op_attrs.dilation,
                  out_dtype,
                  arg0_dtype,
                  arg1_dtype,
                  use_3xtf32,
                  split_k_slices,
                  profile_all_alignments,
                  find_first_valid,
                  use_multiprocessing,
              )
          )
      elif "batch_matmul" in op_type:
          new_attrs.update(
              handle_batch_matmul(
                  gemm_profiler,
                  op_type,
                  arg0_shape,
                  arg1_shape,
                  out_dtype,
                  arg0_dtype,
                  arg1_dtype,
                  use_3xtf32,
                  find_first_valid,
                  use_multiprocessing,
              )
          )
      elif "dense" in op_type:
          new_attrs.update(
              handle_dense(
                  gemm_profiler,
                  op_type,
                  arg0_shape,
                  arg1_shape,
                  out_dtype,
                  arg0_dtype,
                  arg1_dtype,
                  use_3xtf32,
                  find_first_valid,
                  use_multiprocessing,
              )
          )
      else:
          raise ValueError(f"{op_type} unsupported composite")
  
      new_attrs = tvm.ir.make_node("DictAttrs", **new_attrs)
      return relay.Function(
          func.params,
          func.body,
          ret_type=func.ret_type,
          type_params=func.type_params,
          attrs=new_attrs,
      )
  
imports: import logging
  import os
  import multiprocessing
  import tvm
  from tvm import relay, runtime
  from tvm._ffi.registry import register_func
  from tvm.contrib.nvcc import get_cuda_version
  from .gen_conv2d import CutlassConv2DProfiler
  from .gen_gemm import CutlassGemmProfiler
  from .library import ConvKind
label_desc: Use image node_id 10 for calling a global function with example usage: tune_cutlass_function(func, use_3xtf32, split_k_slices, profile_all_alignments, find_first_valid, use_multiprocessing, gemm_profiler, conv2d_profiler) and returns: relay