# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
#default_exp models.majority_label_voter
# -

# # Models
# > Models implementation

#export
from fastai2.basics import *


#export
class MajorityLabelVoter(Module):
    def forward(self, x): 
        preds = []
        for row in x:
            row = row[row!=0]
            if row.numel() == 0: preds.append(0)
            else:                preds.append(row.mode().values.item())
        return tensor(preds).to(x.device)


# ## Export -

#hide
from nbdev.export import notebook2script
notebook2script()

StarcoderdataJupyterScriptsDedupFiltered