from typing import Any
from typing import Callable


def verify_operands_classes_and_forward_to_callable(
    x_operand: Any,
    y_operand: Any,
    operand_class: type,
    function: Callable[[Any, Any], Any],
) -> Any:
    """
    verify_operands_classes_and_forward_to_callable verifies both operands are
    of type operand_class before calling function.

    :param x_operand: First operand.
    :type x_operand: Any
    :param y_operand: Second operand.
    :type y_operand: Any
    :param operand_class: type to compare against.
    :type operand_class: type
    :param function: callable to call.
    :type function: Callable[[Any, Any], Any]
    :raises TypeError: if either operand is not of operand_class.
    :return: The return value of the callable, in any.
    :rtype: Any
    """
    if isinstance(x_operand, operand_class) and isinstance(y_operand, operand_class):
        return function(x_operand, y_operand)
    raise TypeError("x_operand and y_operand are not both ", operand_class)