Reading the source code for collab filtering. Question about a class

Hello people! I’m reading the source code for collaborative filtering and I had a question.
So we have the collab_learner function that returns the CollabLearner object.

def collab_learner(data, n_factors:int=None, use_nn:bool=False, emb_szs:Dict[str,int]=None, layers:Collection[int]=None, 
               ps:Collection[float]=None, emb_drop:float=0., y_range:OptRange=None, use_bn:bool=True, 
               bn_final:bool=False, **learn_kwargs)->Learner:
"Create a Learner for collaborative filtering on `data`."
emb_szs = data.get_emb_szs(ifnone(emb_szs, {}))
u,m = data.train_ds.x.classes.values()
if use_nn: model = EmbeddingNN(emb_szs=emb_szs, layers=layers, ps=ps, emb_drop=emb_drop, y_range=y_range, 
                               use_bn=use_bn, bn_final=bn_final, **learn_kwargs)
else:      model = EmbeddingDotBias(n_factors, len(u), len(m), y_range=y_range)
return CollabLearner(data, model, **learn_kwargs)

Here’s my question. In the last but final line in the above block of code

else: model = EmbeddingDotBias(n_factors, len(u), len(m), y_range=y_range)

in which EmbeddingDotBias object is being created which is then input into the final line creating the CollabLearner object. BUT the the CollabLearner object seems to inherit from a Learner object(from old fastai)

Neither does CollabLearner have super init nor does the Learner take an input called ‘model’.
So how does this code not break? What am I missing?

Essentially how does the final line of the above code block make sense keepig the first line of the CollabLearner in persepctive?

class CollabLearner(Learner):
"`Learner` suitable for collaborative filtering."

and Learner is like this?

class Learner():
def __init__(self, data, models, opt_fn=None, tmp_name='tmp', models_name='models', metrics=None, clip=None, crit=None):

Not sure if it’s too late but in your example of the Learner class

class Learner():
def __init__(self, data, models, opt_fn=None, tmp_name='tmp', models_name='models', metrics=None, clip=None, crit=None):

It’s clear from the def __init__ method that the class accepts compulsory input parameters “data” and “models”.

In the latest version of fastai library, it uses the @dataclass annotation & added support for typing. Makes it alot clearer the input parameter & type Learner class is expecting when the object is instantiated.

@dataclass
class Learner():
    "Trainer for `model` using `data` to minimize `loss_func` with optimizer `opt_func`."
    data:DataBunch
    model:nn.Module
    opt_func:Callable=AdamW
    loss_func:Callable=None
    metrics:Collection[Callable]=None
    true_wd:bool=True
    bn_wd:bool=True
    wd:Floats=defaults.wd
    train_bn:bool=True
    path:str = None
    model_dir:PathOrStr = 'models'
    callback_fns:Collection[Callable]=None
    callbacks:Collection[Callback]=field(default_factory=list)
    layer_groups:Collection[nn.Module]=None
    add_time:bool=True
    silent:bool=None