maybe,
k, m, c, h, w = 2, 3, 4, 5, 6 
x = torch.randn(k, c, h, w)
y = torch.randn(m, c, h, w)
a = torch.repeat_interleave(x, m).view(k, m, c, h, w)
b = torch.repeat_interleave(y, k).view(k, m, c, h, w)
ab = torch.cat((a, b), dim=2)