The MNIST example gives a relatively short example of batched training:
examples/main.py at master · pytorch/examples (github.com) 1, primarily through the use of a DataLoader: torch.utils.data — PyTorch 1.9.1 documentation.