This use case seems to work, as I get valid gradients:
x = torch.randn(10, 10)
lin1 = nn.Linear(10, 10)
lin2 = nn.Linear(10, 10)

out = lin1(x)
out = RBF(out)
out = lin2(out)
out.mean().backward()
print(lin1.weight.grad)
print(lin2.weight.grad)