when I run the code below,
    @torch.no_grad()
    def draw_landmarks(self, imgs, landmarks, colour=[255, 0, 0]):
        """draw landmarks on images inplace
        Arguments:
            imgs {[npndarray]} -- [image with shape BxCxHxW]
            landmarks {[Tensor]} -- [integers with shape BxNx2]
        Keyword Arguments:
            colour {list} -- [description] (default: {[255, 0, 0]})
        """
        with torch.no_grad():
            assert imgs.shape[0] == landmarks.shape[0]
            for i in range(imgs.shape[0]):
                img_landmarks = landmarks[i]
                lm_x, lm_y = img_landmarks[:,0], img_landmarks[:,1]
                imgs[i, :, lm_y, lm_x] = colour
            return imgs
        

landmarks variable contains gradient information, which isn’t required here (as this is for visualization only). However, pytorch throws “cannot call numpy on variable requires gradient” if I don’t call detach for the input variable.
Is this expected behaviour, if so, isn’t this counter-intuitive?
Thank you!