def test_compile_transformer():
    """Smoke test to ensure the transformer model compiles without errors."""
    transformer = Transformer(vocab_size=8)
    transformer = torch.compile(transformer)
    inputs = torch.randint(0, transformer.vocab_size, size=(2, 8))
    targets = torch.randint(0, transformer.vocab_size, size=(2, 8))
    for i in range(3):
        transformer(inputs, targets).sum().backward()
Smoke test to ensure the transformer model compiles without errors.
tests/tests_pytorch/demos/transformer.py