from typing import Any
from typing import Optional
import torch


def _check_are_tensors(a: Any, b: Any) -> Optional[AssertionError]:
    """Checks if both inputs are tensors.

    Args:
        a (Any): First input.
        b (Any): Second input.

    Returns:
        (Optional[AssertionError]): If check did not pass.
    """
    if not (isinstance(a, torch.Tensor) and isinstance(b, torch.Tensor)):
        return AssertionError(f"Both inputs have to be tensors, but got {type(a)} and {type(b)} instead.")

    return None