def getAction2(self, state):
        state = torch.FloatTensor(state) 
        logits, _ = self.model2.forward(state)
        dist = F.softmax(logits, dim = -1)
        self.check2.append(dist)
        probs = Categorical(dist)
        return probs.sample()

i have collected the output of the softmax at the point where the error is raised in the code. It has generated Nan values.
The error:

  File "<ipython-input-12-986f834e9152>", line 1, in <module>
    runfile('C:/Users/Prudhvinath.DESKTOP-09Q8801/sciebo/Thesis/JSSP/TwoAgents/20JobsTwoAgents.py', wdir='C:/Users/Prudhvinath.DESKTOP-09Q8801/sciebo/Thesis/JSSP/TwoAgents')

  File "C:\Users\Prudhvinath.DESKTOP-09Q8801\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\Prudhvinath.DESKTOP-09Q8801\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Prudhvinath.DESKTOP-09Q8801/sciebo/Thesis/JSSP/TwoAgents/20JobsTwoAgents.py", line 406, in <module>
    generateEpisode(x)

  File "C:/Users/Prudhvinath.DESKTOP-09Q8801/sciebo/Thesis/JSSP/TwoAgents/20JobsTwoAgents.py", line 337, in generateEpisode
    action = agent.getAction2(state)

  File "C:/Users/Prudhvinath.DESKTOP-09Q8801/sciebo/Thesis/JSSP/TwoAgents/20JobsTwoAgents.py", line 179, in getAction2
    return probs.sample()

  File "C:\Users\Prudhvinath.DESKTOP-09Q8801\Anaconda3\lib\site-packages\torch\distributions\categorical.py", line 107, in sample
    sample_2d = torch.multinomial(probs_2d, 1, True)

RuntimeError: invalid multinomial distribution (encountering probability entry < 0)

checking for the output of the softmax and I have already made an agent instance.
In [13]: agent.check2
Out[13]: [tensor([nan, nan], grad_fn=<SoftmaxBackward>)]

so the softmax is creating the Nans.