from typing import Union
from typing import Any
import ipaddress


def check_ip(val: Union[str, Any]) -> Any:
    """
    Function to check whether a value is valid ip address
    """
    try:
        return bool(ipaddress.ip_address(val))
    except ValueError:
        return False