# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/100b_models_utils.ipynb (unless otherwise specified).

__all__ = ['get_layers', 'count_params']

# Cell
from ..imports import *

# Cell
def get_layers(model, cond=noop):
    if isinstance(model, Learner): model=model.model
    return [m for m in flatten_model(model) if any([c(m) for c in L(cond)])]

def count_params(model):
    if isinstance(model, Learner): model = model.model
    count = 0
    for l in get_layers(model):
        for i in range(len(list(l.parameters()))):
            count += len(list(l.parameters())[i].data.flatten())
    return count