Indeed, you confused me.
My impression was that you had data similar to
scores = Variable(torch.randn(2,4,3,3))
targets = torch.zeros(1,3,3).long()
targets[:,2,1] = 3
targets = Variable(targets)
targets = targets.expand(scores.size(0),*targets.size()[1:]) # if you only have one target per batch

and wanted
ce_fn_1 = torch.nn.CrossEntropyLoss()
ce_fn_1(scores[:,:,2,1], targets[:,2,1])

which is very similar to
ce_fn_2 = torch.nn.CrossEntropyLoss(weight=torch.Tensor([0.0,1.0,1.0,1.0]))
ce_fn_2(scores.transpose(1,2).transpose(2,3).contiguous().view(-1, scores.size(1)), 
        targets.contiguous().view(-1))

Best regards
Thomas