| 173 | |
| 174 | |
| 175 | class FTHFDebertaModel(): |
| 176 | def __init__(self, ft_model, remove_padding=True): |
| 177 | self.model = ft_model |
| 178 | self.remove_padding = remove_padding |
| 179 | |
| 180 | def __call__(self, input_ids, attention_mask, **kwargs): |
| 181 | seq_len = tf.reduce_sum(attention_mask, axis=1) |
| 182 | outputs = self.model.forward(input_ids, seq_len, remove_padding=self.remove_padding) |
| 183 | |
| 184 | # to match HF structure |
| 185 | FTOutput = namedtuple("FTOutput", ["output", "hidden_states", "attentions"]) |
| 186 | o = FTOutput(outputs, None, None) |
| 187 | return o |