I tried executing the script with $PYTORCH_JIT=0 as you said and got the following error:

image.png899×497 72.7 KB

As for the runtimeerror. I don’t think there is anything wrong with the code, since it will run in native Pytorch. I also had to comment the istensor lines since they raise a different exception.
I dont know why its not commented in the snippet I pasted but I did comment those lines, so even if the data.shape[-3] is wrong those lines should not run at all.
P.S: -3 requires at least 3 dimensions since the last one is -1.