def METHOD_NAME(clz):
    """
    Decorator taking a class or a function returning an instance of a class
    and replacing the `dtype` argument with `param_dtype`.
    This decorator also adds a deprecated field `dtype` to the class, which
    returns `param_dtype`.
    """
    # Sphinx is terrible at understanding wrappers of classes, so we detect
    # this env variable set by us sphinx's conf.py, and we do not apply the
    # decorator if that's the case.
    if config.netket_sphinx_build:
        return clz
    # If it is a class, then add the deprecated dtype attribute returning
    # `param.dtype`
    # else, if this is a function returning a class, it will be set later
    # on.
    if inspect.isclass(clz):
        lazy = False
        if not hasattr(clz, "dtype"):
            clz.dtype = property(_dtype_deprecated)
    else:
        lazy = True
    @functools.wraps(clz)
    def helper(*args, **kws):
        # deprecated dtype argument
        if "dtype" in kws.keys():
            warn_deprecation(_dep_msg)
            dtype = kws.pop("dtype")
            kws["param_dtype"] = dtype
        res = clz(*args, **kws)
        if lazy:
            _clz = type(res)
            if not hasattr(_clz, "dtype"):
                _clz.dtype = property(_dtype_deprecated)
        return res
    return helper