Perform inference on a batch of data. Args: data: The input data for inference, typically containing tensors and metadata. Returns: Any: The output of the inference, which can be used for predictions or other purposes.
(self, data: TensorDict, loss_function: Optional[Callable] = None)
| 131 | return outputs |
| 132 | |
| 133 | def infer_batch(self, data: TensorDict, loss_function: Optional[Callable] = None) -> Any: |
| 134 | """ |
| 135 | Perform inference on a batch of data. |
| 136 | |
| 137 | Args: |
| 138 | data: The input data for inference, typically containing tensors and metadata. |
| 139 | |
| 140 | Returns: |
| 141 | Any: The output of the inference, which can be used for predictions or other purposes. |
| 142 | """ |
| 143 | # see comments from train_batch |
| 144 | maybe_fix_3d_position_ids(data) |
| 145 | |
| 146 | with torch.no_grad(): |
| 147 | outputs = self.forward_backward_batch(data, loss_function, forward_only=True) |
| 148 | return outputs |
| 149 | |
| 150 | def get_per_tensor_param(self) -> tuple[Generator[tuple[str, torch.Tensor], None, None], Optional[dict]]: |
| 151 | """ |