I can’t reproduce the issue using:
x1 = torch.randn(4, 8)
x2 = torch.randn(2, 16)
edge_index = torch.tensor([[0, 1, 2, 3], [0, 0, 1, 1]])  
conv = TransformerConv(in_channels=-1, out_channels=256)
out = conv(x1, edge_index)

so maybe your torch_geometric version is too old to support the lazy initialization of the layers (I don’t know when it was introduced)?