Actually: I believe this is correct behavior. Indexing a tensor with another tensor produces a copy of the original tensor. So in the code:
data_sigma[data_sigma < 1e-12].fill_(1.0)

you are performing fill_ on a copy of data_sigma, then immediately throwing it away. The TorchScript compiler is correctly recognizing that this is work that you never use the result of, and thus we remove it as an optimization.