    def __init__(self, dim, keepdim=False, dtype=None) -> None:
        """
        Parameters
        ----------
        dim : int or tuple of python:ints
            the dimension or dimensions to reduce
        keepdim : bool
            keep the reduced dimensions if True, default is False
        dtype : optional str
            the type of the return tensor. If it is not None,
            the input tensor is casted to dtype before reduction.
        Raises
        ------
        RuntimeError : duplicate values in the dim list
        """
        super().__init__()
        if isinstance(dim, int):
            dim = [dim]
        elif isinstance(dim, (list, tuple)):
            if not all(isinstance(x, int) for x in dim):
                raise RuntimeError("dim must be either int or a list/tuple of ints.")
            dim = list(dim)
        else:
            raise RuntimeError("dim must be either int or a list/tuple of ints.")
        dup_dims = {d for d in dim if dim.count(dim) > 1}
        if len(dup_dims) > 1:
            raise RuntimeError(
                "dim {d} appears multiple times in the list of dims".format(
                    d=dup_dims[0]
                )
            )
        self._attrs["op"] = "reduce"
        self._attrs["reduction_axes"] = dim
        self._attrs["keepdim"] = keepdim
        self._attrs["output_type"] = dtype
        self._attrs["has_profiler"] = False
Parameters
----------
dim : int or tuple of python:ints
the dimension or dimensions to reduce
keepdim : bool
keep the reduced dimensions if True, default is False
dtype : optional str
the type of the return tensor. If it is not None,
the input tensor is casted to dtype before reduction.
Raises
------
RuntimeError : duplicate values in the dim list
python/aitemplate/compiler/ops/reduce/reduce_common.py