r"""Like `flatten` but lazy.
183888
def iflatten(seq, isSeq=isSeq):
    """
    for elt in seq:
        if isSeq(elt):
            for x in iflatten(elt, isSeq):
                yield x
        else:
            yield elt
330162
function flatten(a) {
  return a.reduce(function(flat, val) {
    if (val && typeof val.flatten === 'function') {
      flat = flat.concat(val.flatten());
    }
    else if (Array.isArray(val)) {
      flat = flat.concat(flatten(val));
    }
    else {
      flat.push(val);
    }
    return flat;
  });
}
782459
def flatten(self, shallow=None):
        
        return self._wrap(self._flatten(self.obj, shallow))
158853
def includeRect(self, r):
        """"""
        if not len(r) == 4:
            raise ValueError("bad sequ. length")
        self.x0, self.y0, self.x1, self.y1 = TOOLS._union_rect(self, r)
        return self
713343
def decomprest(f, rows):
    """"""

    row = 0
    while row < rows:
        row, o = deblock(f)
        yield o
747241
def flatMap(f: Callable, xs: Iterable) -> List:
    
    return flatten(lmap(f, xs))
606680
function flatten(array, target) {
	const result = target || [];

	for (let i = 0; i < array.length; ++i) {
		if (Array.isArray(array[i])) {
			flatten(array[i], result);
		}
		else {
			result.push(array[i]);
		}
	}

	return result;
}
90814
def batchify(data, batch_size):
    """"""
    nbatch = data.shape[0] // batch_size
    data = data[:nbatch * batch_size]
    data = data.reshape((batch_size, nbatch)).T
    return data
172847
def reshape(self, *dims):
        """"""
        shape = _dims2shape(*dims)
        if _volume(shape) != self.size:
            raise ValueError("expected shape with equal volume")
        return self.__class__(self._items, shape, self.ftype)
842921
def reshape(attrs, inputs, proto_obj):
    """"""
    if len(inputs) == 1:
        return 'reshape', attrs, inputs[0]
    reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy())
    reshape_shape = [int(i) for i in reshape_shape]
    new_attrs = {'shape': reshape_shape}
    return 'reshape', new_attrs, inputs[:1]
490812
def lazy(decorator):
    """"""
    def decorate(fn, *args, **kwargs):
        name = fn.__name__
        parent = decorator(fn, *args, **kwargs)
        #doc = _add_msg(getattr(parent, '__doc__', None), '*@lazy*')
        doc = getattr(parent, '__doc__', None)
        if hasattr(parent, '__set__') or hasattr(parent, '__delete__'):
            return _lazy_data(name, parent, doc)
        else:
            return _lazy_nondata(name, parent, doc)
    return decorate
574793
def flatten(nested_list: list) -> list:
    """"""
    return list(sorted(filter(lambda y: y is not None,
                              list(map(lambda x: (nested_list.extend(x)  # noqa: T484
                                                  if isinstance(x, list) else x),
                                       nested_list)))))
934163
def flatten_once(iterable, check=is_iterable):
    """"""
    for value in iterable:
        if check(value):
            for item in value:
                yield item
        else:
            yield value
550016
def flatten(l):
    """"""
    return sum(map(flatten, l), []) \
        if isinstance(l, list) or isinstance(l, tuple) else [l]
257349
def nest(thing):
    """"""
    tfutil = util.get_module('tensorflow.python.util')
    if tfutil:
        return tfutil.nest.flatten(thing)
    else:
        return [thing]
704721
def flatten(attrs, inputs, proto_obj):
    """"""
    #Mxnet does not have axis support. By default uses axis=1
    if 'axis' in attrs and attrs['axis'] != 1:
        raise RuntimeError("Flatten operator only supports axis=1")
    new_attrs = translation_utils._remove_attributes(attrs, ['axis'])
    return 'Flatten', new_attrs, inputs
328182
def unflatten_optimizer(optimize):
    """"""
    @wraps(optimize)
    def _optimize(grad, x0, callback=None, *args, **kwargs):
        _x0, unflatten = flatten(x0)
        _grad = lambda x, i: flatten(grad(unflatten(x), i))[0]
        if callback:
            _callback = lambda x, i, g: callback(unflatten(x), i, unflatten(g))
        else:
            _callback = None
        return unflatten(optimize(_grad, _x0, _callback, *args, **kwargs))

    return _optimize