(self,
labels: List[str],
device: Optional[torch.device] = None)
| 111 | ] |
| 112 | |
| 113 | def encode(self, |
| 114 | labels: List[str], |
| 115 | device: Optional[torch.device] = None) -> Tensor: |
| 116 | batch = [self.bos_id] + self._tok2ids(labels) + [self.eos_id] |
| 117 | return batch |
| 118 | # return pad_sequence(batch, batch_first=True, padding_value=self.pad_id) |
| 119 | |
| 120 | def _filter(self, probs: Tensor, ids: Tensor) -> Tuple[Tensor, List[int]]: |
| 121 | ids = ids.tolist() |