TypeError: expected np.ndarray (got NoneType)

I am using PPO algorithm for my project. I am getting this error. I have used the following line of code:
state = torch.from_numpy(state).float().unsqueeze(0)

I also changed to state = torch.tensor(state).float().unsqueeze(0) then another error arises. It called :
RuntimeError: Could not infer dtype of NoneType

state seems to be None as seen here:

state = None
state = torch.from_numpy(state).float().unsqueeze(0)
# TypeError: expected np.ndarray (got NoneType)
state = torch.tensor(state).float().unsqueeze(0) 
# RuntimeError: Could not infer dtype of NoneType

state = np.random.randn(10)
state = torch.from_numpy(state).float().unsqueeze(0) # works

so make sure it’s a valid numpy array and the code should work.

Thank you so much for your answer!