def _jit_is_scripting() -> Generator:
    """Workaround for https://github.com/pytorch/pytorch/issues/67146."""
    LightningModule._jit_is_scripting = True
    try:
        yield
    finally:
        LightningModule._jit_is_scripting = False
Workaround for https://github.com/pytorch/pytorch/issues/67146.
src/lightning/pytorch/core/module.py