code: def hexagon(cpu_ver="v68", **kwargs):
      """Returns a Hexagon target.
  
      Parameters
      ----------
      cpu_ver : str (default: "v68")
          CPU version used for code generation. Not all allowed cpu str
          will be valid, LLVM will throw an error.
  
      Recognized keyword parameters
      -----------------------------
      hvx : int (default: 128)
          Size of HVX vector in bytes. Value of 0 disables HVX codegen.
      llvm_options : str or list of str (default: None)
          User defined compiler arguments.
      use_qfloat : bool (default: True for cpu_ver >= v68, False otherwise)
          Whether to use QFloat HVX instructions.
      use_ieee_fp : bool (default: False)
          Whether to use IEEE HVX instructions
      num_cores : int (default: 4)
          The number of HVX threads. This attribute is required by meta scheduler.
      vtcm_capacity: int (default: 0)
          Hexagon VTCM capacity limitation. If the value is 0, the capacity is treated as unbounded.
  
      Note: Floating point support in HVX requires LLVM 14+.
      """
  
      # Some of the target parameters correspond to target kind attributes
      # listed in src/target/target_kind.cc. For those parameters, their
      # names follow the attribute names with the exception of '_' being used
      # in place of '-'.
  
      # Example compiler arguments
      # llvm -mtriple=hexagon -mcpu=hexagonv68 -mattr=+hvxv68,+hvx-length128b
  
      def get_arch_version(cpu_ver):
          m = re.match(r"v([0-9]+).*", cpu_ver)
          assert m
          return int(m.group(1))
  
      # Check for valid codegen cpu
      valid_hex = [
          "v65",
          "v66",
          "v67",
          "v67t",
          "v68",
          "v69",
          "v71",
          "v73",
      ]
      try:
          cpu_ver = cpu_ver[cpu_ver.index("v") :].lower()
          assert cpu_ver in valid_hex
      except:
          msg = "{} is not a valid Hexagon version\nvalid versions include {}"
          raise ValueError(msg.format(cpu_ver, valid_hex)) from None
  
      def get_vtcm_capacity(cpu_ver):
          one_mb = 2**20
          default_vtcm_sizes = {
              "v65": one_mb // 4,
              "v66": one_mb // 4,
              "v68": 4 * one_mb,
              "v69": 8 * one_mb,
              "v73": 8 * one_mb,
          }
          return default_vtcm_sizes.get(cpu_ver, 0)
  
      # Target configuration:
      arch_version = get_arch_version(cpu_ver)
      config = {
          "hvx": 128,
          "llvm_options": None,
          "use_qfloat": arch_version >= 68,
          "use_ieee_fp": False,
          "vtcm_capacity": get_vtcm_capacity(cpu_ver),
      }
      config.update(kwargs)
  
      # Warn about obsolete parameter names.
      if config.get("sim_args") or config.get("sim_options"):
          msg = (
              "Setting simulator options in target is deprecated, set environment variable "
              "HEXAGON_SIM_ARGS instead"
          )
          warnings.warn(msg, stacklevel=2)
      if config.get("llvm_args"):
          msg = "The keyword parameter 'llvm_args' is deprecated, use 'llvm_options' instead"
          warnings.warn(msg, stacklevel=2)
          config.update({"llvm_options": config["llvm_args"]})
  
      # LLVM target string
      def create_llvm_target(cpu_ver, config):
          """Create LLVM target string."""
  
          target = " -mtriple=hexagon"
          mcpu = " -mcpu=hexagon" + cpu_ver
  
          # Process the options that affect target features and return the
          # target feature string.
          def create_target_features(config):
              features = {
                  "use_qfloat": "hvx-qfloat",
                  "use_ieee_fp": "hvx-ieee-fp",
              }
              tfs = []
              if config["hvx"] > 0:
                  valid_hvx = [0, 64, 128]
                  if not config["hvx"] in valid_hvx:
                      raise ValueError(
                          "Invalid hvx value, should be one of "
                          + str(valid_hvx)
                      )
                  tfs += [
                      "+hvx" + cpu_ver,
                      "+hvx-length" + str(config["hvx"]) + "b",
                  ]
              else:
                  tfs += ["-hvx"]
              # All the additional features happen to only apply to v68+.
              # Don't bother applying them (even with '-') to lower versions.
              if arch_version >= 68:
                  tfs += [
                      "-+"[config[f]] + features[f] for f in features
                  ]
  
              return "-mattr=" + ",".join(tfs) if tfs else ""
  
          return target + mcpu + " " + create_target_features(config)
  
      # LLVM options string
      def create_llvm_options(
          cpu_ver, config
      ):  # pylint: disable=unused-argument
          """Create LLVM options string."""
  
          llvm_options = config["llvm_options"]
  
          # To enable auto-vectorization for v68 target added the below llvm-option by default
          if arch_version == 68:
              if not llvm_options:
                  llvm_options = ""
              llvm_options += " -force-hvx-float"
  
          # TVM's option parser doesn't allow '=' in values, but '=' can
          # appear in LLVM flags. Replace it with '@', since it's unlikely
          # that '@' will be used in another context.
          if llvm_options is None or len(llvm_options.strip()) == 0:
              return ""
          args = [s.replace("=", "@") for s in llvm_options.split()]
          return "--llvm-options=" + ",".join(args)
  
      target_str = create_llvm_target(cpu_ver, config)
      llvm_str = create_llvm_options(cpu_ver, config)
  
      args_list = target_str.split() + llvm_str.split()
  
      num_cores = config["num_cores"] if "num_cores" in kwargs else 4
      args_list.append("--num-cores=%d" % num_cores)
      args_list.append("--vtcm-capacity=%d" % config["vtcm_capacity"])
  
      return Target(" ".join(["hexagon"] + args_list))
  
imports: import json
  import re
  import warnings
  from typing import Union
  import tvm._ffi
  from tvm._ffi import register_func
  from tvm._ffi.runtime_ctypes import Device
  from tvm.runtime import Object, convert
  from tvm.runtime.container import String
  from tvm.ir.container import Map, Array
  from .None import _ffi_api
label_desc: Use image node_id 12 for calling a global function with example usage: hexagon(cpu_ver) and returns: Target, int, default_vtcm_sizes, unknown, unknown, unknown, str