Take a look at the documentation for set_subtensor. It does not alter the input variable, but rather returns a copy with the changes made
set_subtensor