(self, instances: Sequence[Dict])
| 218 | tokenizer: transformers.PreTrainedTokenizer |
| 219 | |
| 220 | def naive__call__(self, instances: Sequence[Dict]) -> Dict[str, torch.Tensor]: |
| 221 | input_ids, labels = tuple([instance[key] for instance in instances] for key in ("input_ids", "labels")) |
| 222 | input_ids = torch.nn.utils.rnn.pad_sequence( |
| 223 | input_ids, batch_first=True, padding_value=self.tokenizer.pad_token_id |
| 224 | ) |
| 225 | labels = torch.nn.utils.rnn.pad_sequence(labels, batch_first=True, padding_value=IGNORE_INDEX) |
| 226 | return dict( |
| 227 | input_ids=input_ids, |
| 228 | labels=labels, |
| 229 | attention_mask=input_ids.ne(self.tokenizer.pad_token_id), |
| 230 | ) |
| 231 | |
| 232 | def __call__(self, instances: Sequence[Dict]) -> Dict[str, torch.Tensor]: |
| 233 | sources = [] |
nothing calls this directly
no outgoing calls
no test coverage detected