code: def test_x86_target_features(
      min_llvm_version, tvm_target, x86_feature, is_supported
  ):
      """Test X86 features support for different targets.
  
      Parameters
      ----------
      min_llvm_version : int
          Minimal LLVM version.
      tvm_target : str
          TVM target.
      x86_feature : str
          X86 CPU feature.
      is_supported : bool
          Expected result.
      """
  
      ##
      ## no context
      ##
  
      # check for feature via the python api (no explicit target, no context target)
      try:
          assert target_has_features(x86_feature) == is_supported
          assert False
      except tvm.error.InternalError as e:
          msg = str(e)
          assert (
              msg.find(
                  "InternalError: Check failed: (allow_not_defined) is false: Target context required"
              )
              != -1
          )
  
      if isinstance(x86_feature, str):
          # check for feature via the ffi llvm api (no explicit target, no context target)
          try:
              assert (
                  _ffi_api.target_has_feature(x86_feature, None)
                  == is_supported
              )
              assert False
          except tvm.error.InternalError as e:
              msg = str(e)
              assert (
                  msg.find(
                      "InternalError: Check failed: (allow_not_defined) is false: Target context required"
                  )
                  != -1
              )
  
      # skip test on llvm_version
      if LLVM_VERSION < min_llvm_version:
          return
  
      # check for feature via the python api (with explicit target, no context target)
      assert (
          target_has_features(x86_feature, Target(tvm_target))
          == is_supported
      )
      if isinstance(x86_feature, str):
          # check for feature via the ffi llvm api (with explicit target, no context target)
          assert (
              _ffi_api.target_has_feature(
                  x86_feature, Target(tvm_target)
              )
              == is_supported
          )
  
      ##
      ## with context
      ##
  
      with Target(tvm_target):
          mcpu = Target.current(False).mcpu
          # check for feature via the python api (current context target)
          assert target_has_features(x86_feature) == is_supported
          # check for feature via the python api (with explicit target)
          assert (
              target_has_features(x86_feature, Target(tvm_target))
              == is_supported
          )
          # check for feature via the ffi llvm api (current context target)
          (
              sum(
                  _ffi_api.target_has_feature(feat, None)
                  for feat in x86_feature
              )
              > 0
          ) == is_supported
          # check for feature in target's llvm full x86 CPU feature list
          if (not Target(tvm_target).mattr) and isinstance(
              x86_feature, str
          ):
              assert (
                  x86_feature in codegen.llvm_get_cpu_features()
              ) == is_supported
  
imports: import pytest
  import tvm
  from tvm.target import _ffi_api, codegen, Target
  from tvm.target.codegen import target_has_features
label_desc: Use image node_id 1 for calling a global function with example usage: test_x86_target_features(min_llvm_version, tvm_target, x86_feature, is_supported) without return types