Your approach might be right for your use case, but you could also calculate the outer product of batched tensors by using:
batch_size = 10
m, n = 3, 4
a = torch.randn(batch_size, m)
b = torch.randn(batch_size, n)

result = a.unsqueeze(2) * b.unsqueeze(1)
print(result.shape)
> torch.Size([10, 3, 4])