Let’s assume that we have a tensor with shape [batch_size, channel_dim, spatial_dim]:
a = torch.randn(2, 3, 5)
tensor([[[-0.8526,  1.0994, -0.2659, -0.3834,  1.3758],
         [ 0.4018, -0.9505,  0.0167, -0.2450, -1.1768],
         [ 0.9758, -0.7121,  0.7073, -2.0957, -0.8515]],

        [[ 0.4197, -0.0777, -0.0946,  0.1594, -0.0315],
         [-0.1422, -0.8626,  2.9035, -0.5575, -0.4993],
         [-0.7888, -0.5184, -0.7460, -0.4184, -0.2338]]])

The ‘res’ should have the shape of torch.Size([2, 6, 5, 5]) in this case, and given any pair of spatial locations, the pairwise concatenation result should be:
res[0, :, 2, 3] = torch.cat([a[0, :, 2], a[0, :, 3]], dim=-1) 
                = tensor([-0.2659,  0.0167,  0.7073, -0.3834, -0.2450, -2.0957])