In the below code; building the a1 tensor seems to “lose” the gradients - what would be the correct way to use l11 and l12 in further computations that would be included in the backward call?

Ah right; thanks for the pointer; it errors on RuntimeError: zero-dimensional tensor (at position 0) cannot be concatenated and first google gives a few hits which I need to try wrap my head around; but do think that is in the right direction

@CedricLy 's suggestion is the correct way of doing it.

Note that torch.tensor(another_tensor) works like tensor.clone().detach() which causes the trouble you have mentioned.
Also, you are printing a1.grad which gives you a tensor instead of None because it should not be a leaf tensor but because of the torch.tensor(tensor, requires_grad=True), it creates a leaf tensor.

About the second issue, l11 and l12 are scalars but they should be at least 1D tensors which you achieve it by using tensor.unsqueeze(dim).

But as a general tip, if you use any functions other than methods provided by PyTorch, you are breaking the computational graph. So, always try to use PyTorch semantics as it also help you to find bugs later on.
And, following tutorials can help you a lot as they are very well written (and of course documentations).