I want a batch matrix to multiply a 3D matrix, where it works ok when mat2 is 2D
batch_size = 256
mat1 = torch.randn(batch_size,25)
mat2 = torch.randn(25,36)
torch.matmul(mat1, mat2).shape

However, when mat2 is 3D,
batch_size = 256
mat1 = torch.randn(batch_size,25)
mat2 = torch.randn(25,36, 36)
torch.matmul(mat1, mat2).shape

it causes the following errors: RuntimeError: mat1 and mat2 shapes cannot be multiplied.