Function to generate a random CIDR value
    :param 
        lowest_mask: An integer value for the lowest mask you want it to generate
    
    :return: 
        A string of a random CIDR mask
173478
def random_cidr_mask(lowest_mask=16):
    
    if lowest_mask < 33:
        return str(__random.randrange(lowest_mask, 33))

    else:
        LOGGER.critical('{lowest_mask} must be 32 or less.'.format(lowest_mask=lowest_mask))
        raise ValueError('{lowest_mask} must be 32 or less.'.format(lowest_mask=lowest_mask))
484617
def netmask_to_cidr (dq):
  
  if isinstance(dq, str):
    dq = IPv4Address(dq)
  v = int(dq)
  c = 0
  while v & 0x80000000:
    c += 1
    v <<= 1
  v = v & 0xffFFffFF
  if v != 0:
    raise RuntimeError("Netmask %s is not CIDR-compatible" % (dq,))
  return c
91865
def ipv4_prefix_to_mask(prefix):
    
    if prefix > 32 or prefix < 0:
        raise ValueError("invalid cidr prefix for ipv4")
    else:
        mask = ((1 << 32) - 1) ^ ((1 << (32 - prefix)) - 1)
        eight_ones = 255  # 0b11111111
        mask_str = ''
        for i in range(0, 4):
            mask_str = str(mask & eight_ones) + mask_str
            mask = mask >> 8
            if i != 3:
                mask_str = '.' + mask_str
        return mask_str
145587
def interpret_maskval(paramDict):
    
    # interpret user specified final_maskval value to use for initializing
    # output SCI array...
    if 'maskval' not in paramDict:
        return 0
    maskval = paramDict['maskval']
    if maskval is None:
        maskval = np.nan
    else:
        maskval = float(maskval) # just to be clear and absolutely sure...
    return maskval
981259
def create_masked_lm_predictions(tokens, masked_lm_prob, max_predictions_per_seq, vocab_list):
    """"""
    cand_indices = []
    for (i, token) in enumerate(tokens):
        if token == "[CLS]" or token == "[SEP]":
            continue
        cand_indices.append(i)

    num_to_mask = min(max_predictions_per_seq,
                      max(1, int(round(len(tokens) * masked_lm_prob))))
    shuffle(cand_indices)
    mask_indices = sorted(sample(cand_indices, num_to_mask))
    masked_token_labels = []
    for index in mask_indices:
        # 80% of the time, replace with [MASK]
        if random() < 0.8:
            masked_token = "[MASK]"
        else:
            # 10% of the time, keep original
            if random() < 0.5:
                masked_token = tokens[index]
            # 10% of the time, replace with random word
            else:
                masked_token = choice(vocab_list)
        masked_token_labels.append(tokens[index])
        # Once we've saved the true label for that token, we can overwrite it with the masked version
        tokens[index] = masked_token

    return tokens, mask_indices, masked_token_labels
606140
private static long lowMask(char first, char last) {
        long m = 0;
        int f = Math.max(Math.min(first, 63), 0);
        int l = Math.max(Math.min(last, 63), 0);
        for (int i = f; i <= l; i++)
            m |= 1L << i;
        return m;
    }
1331395
def getMaskArray(self, signature):
        
        if signature in self.masklist:
            mask =  self.masklist[signature]
        else:
            mask = None
        return mask
1171845
def _random_block():
    
    # TODO: Use a better RNG than random.randint
    random_number = random.randint(0, DISCRETE_VALUES)
    random_string = _to_base36(random_number)
    return _pad(random_string, BLOCK_SIZE)
786351
def cidr_netmask(cidr):
    '''
    
    '''
    ips = netaddr.IPNetwork(cidr)
    return six.text_type(ips.netmask)
996018
private void calculate(String mask) {
        Matcher matcher = cidrPattern.matcher(mask);

        if (matcher.matches()) {
            matchAddress(matcher);

            /* Create a binary netmask from the number of bits specification /x */
            rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS);
        } else {
            throw new IllegalArgumentException("Could not parse [" + mask + "]");
        }
    }
921660
def ip_in_ip_mask(ip, mask_ip, mask):
    '''
    
    '''
    ip = ip2hex(ip)
    if ip is None: raise Exception("bad ip format")
    if (mask_ip & mask) == (ip & mask):
        return True
    return False
651300
def get_interleave_mask():
    

    nodemask = nodemask_t()
    bitmask = libnuma.numa_get_interleave_mask()
    libnuma.copy_bitmask_to_nodemask(bitmask, byref(nodemask))
    libnuma.numa_bitmask_free(bitmask)

    return numa_nodemask_to_set(nodemask)
716317
def _get_valid_fill_mask(arr, dim, limit):
    ''''''
    kw = {dim: limit + 1}
    # we explicitly use construct method to avoid copy.
    new_dim = utils.get_temp_dimname(arr.dims, '_window')
    return (arr.isnull().rolling(min_periods=1, **kw)
            .construct(new_dim, fill_value=False)
            .sum(new_dim, skipna=False)) <= limit
387196
def iMath_propagate_labels_through_mask(image, labels, stopping_value=100, propagation_method=0):
    
    return iMath(image, 'PropagateLabelsThroughMask', labels, stopping_value, propagation_method)
427953
def pystr(self, min_chars=None, max_chars=20):
        
        if min_chars is None:
            return "".join(self.random_letters(length=max_chars))
        else:
            assert (
                max_chars >= min_chars), "Maximum length must be greater than or equal to minium length"
            return "".join(
                self.random_letters(
                    length=self.generator.random.randint(min_chars, max_chars),
                ),
            )
685732
def generate_random(self, bits_len=None):
        
        bits_len = bits_len or self._bits_random
        return random().getrandbits(bits_len)
261136
def get_submask(self, *args, **kwargs) -> masktools.CustomMask:
        
        if args or kwargs:
            masks = self.availablemasks
            mask = masktools.CustomMask(numpy.full(self.shape, False))
            for arg in args:
                mask = mask + self._prepare_mask(arg, masks)
            for key, value in kwargs.items():
                mask = mask + self._prepare_mask(key, masks, **value)
            if mask not in self.mask:
                raise ValueError(
                    f'Based on the arguments `{args}` and `{kwargs}` '
                    f'the mask `{repr(mask)}` has been determined, '
                    f'which is not a submask of `{repr(self.mask)}`.')
        else:
            mask = self.mask
        return mask