you can call detach() every hundred timesteps to detach the hidden state to it’s previous states.
That way, you will end up with:
without detatch
x -> x -> x -> x-> x-> x-> x-> … -> x -> x-> x -> x -> x -> x-> x-> x-> x->
after detaching every T timesteps
x -> x -> x -> x-> x      x -> x -> x -> x-> x      x -> x -> x -> x-> x      x -> x -> x -> x-> x      x -> x -> x -> x-> x