Ignore_index() in nn.NLLLoss2d()?

I wanted to specify the ignore_index for the nn.NLLLoss2d() criterion in my network, but when I initialize the loss in my script, I get the following error:

  File "trainer.py", line 36, in <module>
    criterion = nn.NLLLoss2d(ignore_index=0)

TypeError: __init__() got an unexpected keyword argument 'ignore_index'

The documentation mentions it, and I can even see in the online source code that the ignore_index is being used in the NLLLoss() class from which NLLLoss2d() inherits.

EDIT: Turns out the ignore_index() has been implemented on GitHub but isn’t on the latest release. So, how can I update the PyTorch packages on my computer to match the github repo, without breaking it’s management by Anaconda?

I think ignore_index() is available in the latest pytorch 2.0. Installing pytorch via pip did not break anything for me, but I am not sure about Anaconda.

Just gonna throw it out there that installing from source in a conda env was super easy, at least on Linux, and it’s really convenient to be able to pull the latest features.