My program ran once, but returned an error when I ran it again.

non_final_next_states).max(1)[0].detach()
RuntimeError: CUDA error: device-side assert triggered

When I tried to use the CPU, it returned the following error.

state_action_values = Policy_Net(state_batch).gather(1, action_batch)
RuntimeError: index 8 is out of bounds for dimension 1 with size 6