def transform(fn: Callable[[Var], Var]) -> Callable[[Var], Var]:
    """Register a function to transform a Var.

    Args:
        fn: The function to register.

    Returns:
        The decorator.

    Raises:
        TypeError: If the return type of the function is not a Var.
        TypeError: If the Var return type does not have a generic type.
        ValueError: If a function for the generic type is already registered.
    """
    return_type = fn.__annotations__["return"]

    origin = get_origin(return_type)

    if origin is not Var:
        msg = f"Expected return type of {fn.__name__} to be a Var, got {origin}."
        raise TypeError(msg)

    generic_args = get_args(return_type)

    if not generic_args:
        msg = f"Expected Var return type of {fn.__name__} to have a generic type."
        raise TypeError(msg)

    generic_type = get_origin(generic_args[0]) or generic_args[0]

    if generic_type in dispatchers:
        msg = f"Function for {generic_type} already registered."
        raise ValueError(msg)

    dispatchers[generic_type] = fn

    return fn
Register a function to transform a Var.

    Args:
        fn: The function to register.

    Returns:
        The decorator.

    Raises:
        TypeError: If the return type of the function is not a Var.
        TypeError: If the Var return type does not have a generic type.
        ValueError: If a function for the generic type is already registered.
    
reflex/vars/base.py