I’ve fixed your PyTorch code as there were some minor issues:
loss = nn.CrossEntropyLoss(reduction='none')
input = torch.tensor([[0.5, 1.5, 0.1], [2.2, 1.3, 1.7]], requires_grad=True)
target = torch.tensor([1, 2], dtype=torch.long)
print(type(input), type(target))
output = loss(input, target)
output.backward(torch.ones_like(target, dtype=torch.float))
print(output)

The first one was that nn.CrossEntropyLoss does not use one-hot encoded targets, but targets storing the class index. To get the loss for both elements, we also have to pass reduction='none' as otherwise the default will be elementwise_mean.
If you want to cast a numpy array in to a tensor, you should use torch.from_numpy instead if directly creating it.
In your tensorflow code it looks like you’ve mixed up labels and logits.