import ipaddress
import socket


def is_valid_ip_network(addr):
    """
    Checks whether address represents a valid IPv4 or IPv6 address,
    or the network doesn't have host bits set.
    (example 'addr': '192.168.0.0/28' or '2001:db8::/46')
    """
    try:
        ipaddress.ip_network(addr)
        return True
    except socket.error:
        return False