A helper wrapper to group together context managers.
(self)
| 2034 | return (loss, outputs) if return_outputs else loss |
| 2035 | |
| 2036 | def compute_loss_context_manager(self) -> contextlib.ExitStack: |
| 2037 | """ |
| 2038 | A helper wrapper to group together context managers. |
| 2039 | """ |
| 2040 | ctx_stack = contextlib.ExitStack() |
| 2041 | |
| 2042 | autocast_ctx = self.autocast_smart_context_manager() |
| 2043 | if not isinstance(autocast_ctx, contextlib.nullcontext): |
| 2044 | ctx_stack.enter_context(autocast_ctx) |
| 2045 | |
| 2046 | return ctx_stack |
| 2047 | |
| 2048 | def autocast_smart_context_manager(self, cache_enabled: bool | None = True) -> contextlib.AbstractContextManager: |
| 2049 | """ |
no test coverage detected