code: def test_target_temp_strategy():
      class TempStrategy(object):
          def __init__(self, name, target, fstrategy):
              generic_fstrategy = tvm.target.get_native_generic_func(
                  name
              )
              self.target = target
              self.name = name
              self.origin_func = {}
              with tvm.target.Target(target) as target_obj:
                  for tgt_key in target_obj.keys:
                      self.origin_func[
                          tgt_key
                      ] = generic_fstrategy.get_packed_func()
                      generic_fstrategy.register(
                          fstrategy, tgt_key, allow_override=True
                      )
  
          def __enter__(self):
              return self
  
          def __exit__(self, typ, value, traceback):
              generic_fstrategy = tvm.target.get_native_generic_func(
                  self.name
              )
              with tvm.target.Target(self.target) as target_obj:
                  for tgt_key in target_obj.keys:
                      generic_fstrategy.register(
                          self.origin_func[tgt_key],
                          tgt_key,
                          allow_override=True,
                      )
  
      with tvm.target.Target("cuda"):
          assert target_generic(1) == 3
  
      # The strategy func change to temp_target_cuda_func.
      with TempStrategy(
          "test_target_temp_strategy", "cuda", temp_target_cuda_func
      ):
          with tvm.target.Target("cuda"):
              assert target_generic(1) == 4
  
      with tvm.target.Target("cuda"):
          assert target_generic(1) == 3
  
imports: import json
  import pytest
  import tvm
  import tvm.testing
  from tvm.target import Target, arm_cpu, bifrost, cuda, intel_graphics, mali, rocm, vta
label_desc: Use image node_id 10 for calling a global function with example usage: test_target_temp_strategy() and returns: self