What type hints do I use for a __torch_function__ function?

    @classmethod
    def __torch_function__(cls, func, types, args=(), kwargs=None):
        logging.info(f"func: {func.__name__}, args: {args!r}, kwargs: {kwargs!r}")
        if kwargs is None:
            kwargs = {}
        return super().__torch_function__(func, types, args, kwargs)

What type hints do I use for the arguments, and what type hint do I use for the return type: -> ReturnType?

After some testing, I think this is how you properly type hint __torch_function__:

from typing import Any, Callable, Dict, Optional, Tuple

class LoggingTensor(torch.Tensor):

    @classmethod
    def __torch_function__(cls, func: Callable, types: Tuple, args: Tuple = (), kwargs: Optional[Dict] = None) -> Any:
        if kwargs is None:
            kwargs = {}
        return super().__torch_function__(func, types, args, kwargs)