code: def test_reduce_map(
      target,
      dev,
      ref_data,
      in_shape,
      axis,
      keepdims,
      reduce_type,
      dtype,
  ):
      target = tvm.target.Target(target)
      if target.kind.name == "vulkan" and reduce_type in [
          "sum",
          "prod",
          "any",
          "all",
      ]:
          pytest.xfail(
              f"Vulkan backend has known errors on {reduce_type}"
          )
  
      in_npy, in_npy_map, out_npy = ref_data
  
      # Build the logic and compile the function
      A = te.placeholder(shape=in_shape, name="A", dtype=dtype)
      A1 = topi.sqrt(topi.exp(A))
      out_dtype = dtype
      if reduce_type == "sum":
          if dtype == "bool":
              B = topi.sum(A, axis=axis, keepdims=keepdims)
          else:
              B = topi.sum(A1, axis=axis, keepdims=keepdims)
      elif reduce_type == "prod":
          B = topi.prod(A1, axis=axis, keepdims=keepdims)
      elif reduce_type == "all":
          B = topi.all(A, axis=axis, keepdims=keepdims)
      elif reduce_type == "any":
          B = topi.any(A, axis=axis, keepdims=keepdims)
      elif reduce_type == "max":
          B = topi.max(A1, axis=axis, keepdims=keepdims)
      elif reduce_type == "min":
          B = topi.min(A1, axis=axis, keepdims=keepdims)
      elif reduce_type == "argmax":
          B = topi.argmax(A1, axis=axis, keepdims=keepdims)
          out_dtype = "int32"
      elif reduce_type == "argmin":
          B = topi.argmin(A1, axis=axis, keepdims=keepdims)
          out_dtype = "int32"
      else:
          raise NotImplementedError
  
      with tvm.target.Target(target):
          s = tvm.topi.testing.get_reduce_schedule(target)(B)
  
      foo = tvm.build(s, [A, B], target, name=reduce_type)
  
      data_tvm = tvm.nd.array(in_npy, device=dev)
      out_tvm = tvm.nd.empty(
          shape=out_npy.shape, device=dev, dtype=out_dtype
      )
      foo(data_tvm, out_tvm)
  
      if reduce_type == "argmax" or reduce_type == "argmin":
          out_tvm_indices = out_tvm.numpy()
          if keepdims:
              out_tvm_indices = np.take(
                  out_tvm_indices, indices=0, axis=axis
              )
          if axis is None:
              out_tvm_val = in_npy_map.ravel()[out_tvm_indices]
          else:
              other_indices = tuple(
                  np.indices(in_shape[0:axis] + in_shape[(axis + 1) :])
              )
              sel_indices = (
                  other_indices[0:axis]
                  + (out_tvm_indices,)
                  + other_indices[axis:]
              )
              out_tvm_val = in_npy_map[sel_indices]
          if reduce_type == "argmax":
              tvm.testing.assert_allclose(
                  out_tvm_val, in_npy_map.max(axis=axis), 1e-3, 1e-3
              )
          elif reduce_type == "argmin":
              tvm.testing.assert_allclose(
                  out_tvm_val, in_npy_map.min(axis=axis), 1e-3, 1e-3
              )
      else:
          tvm.testing.assert_allclose(
              out_tvm.numpy(), out_npy, 1e-3, 1e-3
          )
  
file_path: tvm/tests/python/topi/test_topi_reduce.py
imports: import os
  import sys
  import numpy
  import pytest
  import tvm
  import tvm.testing
  import tvm.topi.testing
  from tvm import te, topi, tir
label_desc: Use image node_id 4 for calling a global function with example usage: test_reduce_map(target, dev, ref_data, in_shape, axis, keepdims, reduce_type, dtype) without return types