For m1: [a * b], m2: [c * d], do ensure that b=c. To illustrate this point
import torch
import torch.nn as nn
batch_size = 12
fc1 = nn.Linear(12,6)
input = torch.randn(batch_size,6)
output = fc1(input)

will throw an error as shown below:

RuntimeError: size mismatch, m1: [12 x 6], m2: [12 x 6] at /pytorch/aten/src/TH/generic/THTensorMath.cpp:136

To correct it, you would have to rewrite it as:
import torch
import torch.nn as nn
batch_size = 16 ### Any arbitarary number
fc1 = nn.Linear(12,6)
input = torch.randn(batch_size,12) ### Making sure the second dimension is qual to 12
output = fc1(input)

In your code, simply taking a transpose of ‘h’ should remove the RunTimeError.