Solved by Naruto-Sasuke in post #2 
              
              
                N, M, V=2, 3, 5
a = torch.randn(N, M, V)
b = torch.randn(M, V, V)
a_expand = a.unsqueeze(-2)
b_expand = b.expand(N, -1, -1, -1)

c = torch.matmul(a_expand, b_expand).squeeze(-2)