Hi @Tomasz_Dryjanski ,
have a look at torch.bmm 14, it computes a matrix multiplication for each corresponding matrix pair.
Here is an example of what you want to do:
import torch

a = torch.Tensor([[1, 2, 3], [4, 5, 6]]).float()
b = torch.Tensor([[[ 1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
                  [[12, 11, 10], [9, 8, 7], [6, 5, 4], [ 3, 2, 1]]]).float()
a = a.unsqueeze(1)  # B, 1, 3

print(a.shape, b.shape)
>> torch.Size([2, 1, 3]) torch.Size([2, 4, 3])

c = torch.bmm(a, b.transpose(1, 2))
c = c.squeeze(1)

print(c)
>> tensor([[ 14.,  32.,  50.,  68.],
           [163., 118.,  73.,  28.]])

albanD will hopefully answer your extra question :^)
Edit example for einsum, which albanD mentioned:
a = torch.Tensor([[1, 2, 3], [4, 5, 6]]).float()
b = torch.Tensor([[[ 1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
                  [[12, 11, 10], [9, 8, 7], [6, 5, 4], [ 3, 2, 1]]]).float()

torch.einsum("bn, bmn -> bm", a, b)