I couldn’t reproduce the error with your script.
But note that the resize function might change the underlying data if the size doesn’t match with the size of the original tensor. In those situations, it’s better to simply use .view, which is guaranteed not to modify your tensor and to error out if the number of elements don’t match