()
| 4 | import numpy as np |
| 5 | |
| 6 | def get_device(): |
| 7 | if torch.backends.mps.is_available(): |
| 8 | return torch.device("mps") |
| 9 | elif torch.cuda.is_available(): |
| 10 | return torch.device("cuda") |
| 11 | else: |
| 12 | return torch.device("cpu") |
| 13 | |
| 14 | def calculate_confidence(logits: List[torch.Tensor], answer_ids: torch.Tensor) -> float: |
| 15 | """ |