def flatten(l):
    if isinstance(l,list) or isinstance(l,tuple):
        return functools.reduce(operator.add, (flatten(x) for x in l), [])
    return [l]
flatten a generator
dataset/ETHPy150Open Microsoft/ivy/src/ivy/ivy_utils.py/flatten