code: def mirror_pad(
      data,
      pad_before,
      pad_after=None,
      mode="SYMMETRIC",
      name="MirrorPadInput",
  ):
      """Pad Input with mirroring either symmetric or reflected.
  
      Parameters
      ----------
      data : tvm.te.Tensor
          n-D input, can be any layout.
  
      pad_before : list / tuple of n ints
          Pad width on each dimension to pad the before the axis begin.
  
      pad_after : list / tuple of n ints, optional
          Pad width each dimension to pad the after the axis end.
  
      mode: str, optional
          Type of mirror padding to apply. Must be SYMMETRIC or REFLECT
  
      name : str, optional
          The name prefix operators generated
  
      Returns
      -------
      Output : tvm.te.Tensor
          n-D, the same layout as Input.
      """
      n = len(data.shape)
      pad_after = pad_after if pad_after else pad_before
      if len(pad_before) != n:
          raise ValueError(
              f"Input dimension and pad_before dismatch : {n} vs {len(pad_before)}"
          )
      if len(pad_after) != n:
          raise ValueError(
              f"Input dimension and pad_after dismatch : {n} vs {len(pad_after)}"
          )
      ana = tvm.arith.Analyzer()
      out_shape = tuple(
          ana.simplify(data.shape[i] + pad_before[i] + pad_after[i])
          for i in range(n)
      )
      assert mode in ("SYMMETRIC", "REFLECT")
      mode = int(mode == "SYMMETRIC")
  
      def _pad(*indices):
          index_tuple = []
          above = []
          below = []
          for i in range(n):
              if equal_const_int(pad_before[i], 0) and equal_const_int(
                  pad_after[i], 0
              ):
                  index_tuple.append(indices[i])
                  above.append(False)
                  below.append(False)
              else:
                  index_tuple.append(indices[i] - pad_before[i])
                  above.append(
                      indices[i] >= data.shape[i] + pad_before[i]
                  )
                  below.append(indices[i] < pad_before[i])
          mapped_tuple = []
          for i, axis in enumerate(index_tuple):
              mapped_axis = tvm.tir.if_then_else(
                  below[i], -axis - mode, axis
              )
              mapped_axis = tvm.tir.if_then_else(
                  above[i],
                  (2 * (data.shape[i] - 1)) - axis + mode,
                  mapped_axis,
              )
              mapped_tuple.append(mapped_axis)
          return data(*mapped_tuple)
  
      return te.compute(out_shape, _pad, name=name)
  
imports: from __future__ import absolute_import
  import tvm
  from tvm import te
  from ..None import tag
  from ..utils import equal_const_int
label_desc: Use image node_id 2 for calling a global function with example usage: mirror_pad(data, pad_before, pad_after, mode, name) and returns: te, data