Tests that exactly N items in an iterable are "truthy" (neither None,
    False, nor 0).
544373
def exactly_n(l, n=1):
    '''
    
    '''
    i = iter(l)
    return all(any(i) for j in range(n)) and not any(i)
457802
def is_monotonic(full_list):
    
    prev_elements = set({full_list[0]})
    prev_item = full_list[0]

    for item in full_list:
        if item != prev_item:
            if item in prev_elements:
                return False
            prev_item = item
            prev_elements.add(item)

    return True
935770
def notUnique(iterable, reportMax=INF):
    
    hash = {}
    n=0
    if reportMax < 1:
        raise ValueError("`reportMax` must be >= 1 and is %r" % reportMax)
    for item in iterable:
        count = hash[item] = hash.get(item, 0) + 1
        if count > 1:
            yield item
            n += 1
            if n >= reportMax:
                return
1074622
def n_at_a_time(
    items: List[int], n: int, fillvalue: str
) -> Iterator[Tuple[Union[int, str]]]:
    
    it = iter(items)
    return itertools.zip_longest(*[it] * n, fillvalue=fillvalue)
218350
def find_equals_true_or_false(node):
    """"""
    return (
        isinstance(node, ast.Compare)
        and len(node.ops) == 1
        and isinstance(node.ops[0], ast.Eq)
        and any(h.is_boolean(n) for n in node.comparators)
    )
467482
public static boolean contains(Iterable<?> iterable, Object value)
    {
        if (iterable instanceof Collection)
        {
            return ((Collection<?>) iterable).contains(value);
        }
        if (iterable instanceof RichIterable)
        {
            return ((RichIterable<?>) iterable).contains(value);
        }
        return IterableIterate.detectIndex(iterable, Predicates.equal(value)) > -1;
    }
515864
def isfinite(data: mx.nd.NDArray) -> mx.nd.NDArray:
    
    is_data_not_nan = data == data
    is_data_not_infinite = data.abs() != np.inf
    return mx.nd.logical_and(is_data_not_infinite, is_data_not_nan)
543662
def issuperset(self, items):
        
        return all(_compat.map(self._seen.__contains__, items))
33709
def satisfy_exact_match(self, args, kwargs):
        

        if self.args is None and self.kwargs is None:
            return False
        elif self.args is _any and self.kwargs is _any:
            return True
        elif args == self.args and kwargs == self.kwargs:
            return True
        elif len(args) != len(self.args) or len(kwargs) != len(self.kwargs):
            return False

        if not all(x == y or y == x for x, y in zip(args, self.args)):
            return False

        for key, value in self.kwargs.items():
            if key not in kwargs:
                return False
            elif not (kwargs[key] == value or value == kwargs[key]):
                return False

        return True
378643
def ptake(n: int, xs: Iterable[T]) -> Iterable[T]:
    
    return tqdm(take(n, xs), total=n)
411630
def is_list_of_list(item):
    
    if (
        type(item) in (list, tuple)
        and len(item)
        and isinstance(item[0], (list, tuple))
    ):
        return True
    return False
929671
def _is_pair(item):
    
    return (isinstance(item, (list, tuple, set)) and
            len(item) == 2 and
            not isinstance(item[0], (list, tuple, set)) and
            not isinstance(item[1], (list, tuple, set)))
1277389
def assert_single_element(iterable):
  
  it = iter(iterable)
  first_item = next(it)

  try:
    next(it)
  except StopIteration:
    return first_item

  raise ValueError("iterable {!r} has more than one element.".format(iterable))
1158150
def first_true(iterable, func):
    # type: (Iterable[T], Callable) -> T
    "
    try:
        return next((x for x in iterable if func(x)))
    except StopIteration as e:
        # TODO: Find a better error message
        raise_from(IndexError('No match for %s' % func), e)
472253
def rand_bool(p:float, size:Optional[List[int]]=None)->BoolOrTensor:
    ""
    return uniform(0,1,size)<p
1048106
def is_true(key, default=False):
    
    value = get(key, default)
    if isinstance(value, list):
        value = value[0]
    if isinstance(value, bool):
        return value
    if value is default:
        return default
    return value.lower() in TRUE_VALUES
703932
def is_iterable_of_int(l):
     """
    if not is_iterable(l):
        return False

    return all(is_int(value) for value in l)