def _reduce_method(  # type: ignore[misc]
        name: str,
        fillna: Any,
        rolling_agg_func: Callable | None = None,
        automatic_rechunk: bool = False,
    ) -> Callable[..., T_Xarray]:
        """Constructs reduction methods built on a numpy reduction function (e.g. sum),
        a numbagg reduction function (e.g. move_sum), a bottleneck reduction function
        (e.g. move_sum), or a Rolling reduction (_mean).

        The logic here for which function to run is quite diffuse, across this method &
        _array_reduce. Arguably we could refactor this. But one constraint is that we
        need context of xarray options, of the functions each library offers, of
        the array (e.g. dtype).

        Set automatic_rechunk=True when the reduction method makes a memory copy.
        """
        if rolling_agg_func:
            array_agg_func = None
        else:
            array_agg_func = getattr(duck_array_ops, name)

        bottleneck_move_func = getattr(bottleneck, "move_" + name, None)
        if module_available("numbagg"):
            import numbagg

            numbagg_move_func = getattr(numbagg, "move_" + name, None)
        else:
            numbagg_move_func = None

        def method(self, keep_attrs=None, **kwargs):
            keep_attrs = self._get_keep_attrs(keep_attrs)

            return self._array_reduce(
                array_agg_func=array_agg_func,
                bottleneck_move_func=bottleneck_move_func,
                numbagg_move_func=numbagg_move_func,
                rolling_agg_func=rolling_agg_func,
                keep_attrs=keep_attrs,
                fillna=fillna,
                sliding_window_view_kwargs=dict(automatic_rechunk=automatic_rechunk),
                **kwargs,
            )

        method.__name__ = name
        method.__doc__ = _ROLLING_REDUCE_DOCSTRING_TEMPLATE.format(name=name)
        return method
Constructs reduction methods built on a numpy reduction function (e.g. sum),
        a numbagg reduction function (e.g. move_sum), a bottleneck reduction function
        (e.g. move_sum), or a Rolling reduction (_mean).

        The logic here for which function to run is quite diffuse, across this method &
        _array_reduce. Arguably we could refactor this. But one constraint is that we
        need context of xarray options, of the functions each library offers, of
        the array (e.g. dtype).

        Set automatic_rechunk=True when the reduction method makes a memory copy.
        
xarray/computation/rolling.py