<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _prefix_from_ip_int(self, ip_int):
 """Return prefix length from a bitwise netmask. Args: ip_int: An integer, the netmask in expanded bitwise format. Returns: An integer, the prefix length. Raises: NetmaskValueError: If the input is not a valid netmask. """

        prefixlen = self._max_prefixlen
        while prefixlen:
            if ip_int & 1:
                break
            ip_int >>= 1
            prefixlen -= 1

        if ip_int == (1 << prefixlen) - 1:
            return prefixlen
        else:
            raise NetmaskValueError('Bit pattern does not match /1*0*/')