because torch.sigmoid saves its output to use in the backward computation, modifying the output of sigmoid “b” in-place will result in an error. If you split torch.sigmoid such that the last out of place operation is a division, that actually saves its input for backward, so it doesn’t care if you modified the output in-place.
index_fill is an out-of-place op, when you do b = b.index_fill(...) you are just changing what object “b” points to.