The error is raised, if a and b have less that two dimensions, while torch.cat tries to concatenate these tensors in dim1. Here is an example:
# both tensors have a single dimension
a, b = torch.randn(10), torch.randn(10)
x = torch.cat([a, b], 1)
> IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

# works
a, b = torch.randn(10, 1), torch.randn(10, 1)
x = torch.cat([a, b], 1)

Make sure that both tenors have at least 2 dimensions before passing them into the forward method.