MyST Directives Test Page#
Created On: May 19, 2026 | Last Updated On: May 19, 2026
This page tests all common MyST and sphinx-design directives to verify they render correctly with the PyTorch Sphinx theme.
Dropdowns#
Basic Dropdown#
More details on mutation and aliasing
custom_op asks for a precise mutation and aliasing contract because PyTorch
uses that contract in FakeTensor, autograd, functionalization, and
torch.compile.
For a functional custom_op, PyTorch assumes the operator does not mutate
any input and that returned tensors are fresh values. This is the easiest
kind of op to set up for torch.compile.
For an in-place custom_op, torch.Tag.inplace gives PyTorch a stronger
and more specific contract: the first argument and the returned object are
the same object. This lets PyTorch derive the fake-tensor behavior from
the schema instead of requiring a separate fake kernel.
Dropdown with Title and Open by Default#
Click to expand this section
This dropdown is open by default. It contains some code:
import torch
x = torch.randn(3, 4)
print(x)
Dropdown with Admonition Style#
Important implementation note
This is a dropdown styled as a warning. Be careful when using this API as it may change in future versions.
Point one about the API
Point two about compatibility
Point three about deprecation timeline
Tip: Performance optimization
Use torch.compile for best performance:
model = torch.compile(model)
Admonitions#
Note
This is a note admonition. Use it to highlight important information.
Warning
This is a warning. Proceed with caution when using experimental APIs.
Tip
Use torch.no_grad() context manager to disable gradient computation
during inference for better performance.
Important
Always call model.eval() before inference and model.train() before training.
Caution
Mixing CPU and CUDA tensors in operations will raise a RuntimeError.
Danger
Never store sensitive data in model checkpoint files without encryption.
See also
See the PyTorch documentation for more details.
Hint
You can use torch.cuda.is_available() to check for GPU availability.
Custom Titled Admonition#
Custom Title Here
This is an admonition with a custom title styled as a tip.
Tab Sets#
Use Python for most deep learning tasks:
import torch
x = torch.tensor([1.0, 2.0, 3.0])
Use the C++ frontend for production:
#include <torch/torch.h>
auto x = torch::tensor({1.0, 2.0, 3.0});
Use the CLI for quick experiments:
python -m torch.utils.benchmark
Cards#
Standalone Card#
Learn the basics of PyTorch with our beginner tutorials. Covers tensors, autograd, neural networks, and more.
Card Grid#
Learn how to train models with PyTorch.
Deploy models to production with TorchServe.
Definition Lists#
- Term 1
Definition of the first term. This can span multiple lines.
- Term 2
Definition of the second term.
torch.TensorThe main data structure in PyTorch. A multi-dimensional matrix containing elements of a single data type.
Field Lists#
- Author:
PyTorch Team
- Version:
2.0
- Status:
Stable
- License:
BSD-3
Task Lists#
Install PyTorch
Set up development environment
Train first model
Deploy to production
Substitutions#
This project is called PyTorch version 2.0.
Code Blocks#
1import torch
2import torch.nn as nn
3
4model = nn.Linear(10, 5)
5x = torch.randn(3, 10)
6output = model(x)
7print(output.shape)
pip install torch torchvision torchaudio
Math#
Inline math: \(E = mc^2\)
Tables#
Optimizer |
Description |
Learning Rate |
Momentum |
|---|---|---|---|
SGD |
Stochastic Gradient Descent |
0.01 |
0.9 |
Adam |
Adaptive Moment Estimation |
0.001 |
N/A |
AdamW |
Adam with weight decay |
0.001 |
N/A |
Figures#
The PyTorch logo.#
Block Attributes#
The attrs_block extension lets you attach HTML attributes (classes, IDs) to
the next block element using {.classname} or {#id} syntax.
This paragraph is styled with the sd-text-primary class via attrs_block.
This paragraph has a light background, padding, and rounded corners.
Toggles (Nested Dropdowns)#
Outer dropdown
This is the outer content.
Inner dropdown
This is nested inside the outer dropdown.
Sphinx-Design Containers#
Column 1
Content in the first column of a responsive grid.
Column 2
Content in the second column.
Column 3
Content in the third column. On mobile, all columns stack vertically.