Thank you for the reply.
Indeed, the long tensor cannot have gradient. Then, i wonder if we can make the differentiable indices for the function image.index_put_(indices, values, accumulate=True) ? The indices are the pixel location, which has requires_grad and is computed from the leaf tensor. image is a zero tensors. I want to write some values for specific pixels into image. Is it possible to allow a differentiable indices in this case?