{"record":{"id":"12e035d11d8bc4e8","repo":"rohitg00/ai-engineering-from-scratch","slug":"torch-is-required-for-this-lesson-install-with-p","errorCode":null,"errorMessage":"torch is required for this lesson. Install with: pip install torch","messagePattern":"torch is required for this lesson\\. Install with: pip install torch","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py","lineNumber":30,"sourceCode":"steps on a fixed batch, prints a per-step log, and renders the schedule.\nRun: python3 code/main.py\n\"\"\"\n\nfrom __future__ import annotations\n\nimport csv\nimport dataclasses\nimport math\nimport sys\nfrom dataclasses import dataclass, field\nfrom pathlib import Path\nfrom typing import Callable, Iterable\n\ntry:\n    import torch\n    from torch import nn\nexcept ImportError as exc:\n    raise SystemExit(\n        \"torch is required for this lesson. Install with: pip install torch\"\n    ) from exc\n\n\nPLOT_HEIGHT = 12\nPLOT_WIDTH = 60\n\n\n@dataclass\nclass CosineWithWarmup:\n    \"\"\"Stateless cosine-with-warmup learning-rate schedule.\n\n    Step indexing convention: step zero is the very first training update. At\n    step zero the rate is exactly zero (the warmup ramp starts there). At\n    step warmup_steps the rate is exactly lr_max. At step total_steps the\n    rate is exactly lr_min. Past total_steps the rate stays at lr_min.\n    \"\"\"\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py#L12-L48","documentation":"Error \"torch is required for this lesson. Install with: pip install torch\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}