def METHOD_NAME(self, x):
    eps = 1e-6
    n, c, h, w = x.shape
    if h <= 1 or w <= 1:
        raise ValueError(
            'The width and height of tensor to compute grad must be greater than 1, but the shape is {}.'
            .format(x.shape))
    x = self.conv_tri(x, r=4)
    kernel = [[-1, 0, 1]]
    kernel = paddle.to_tensor(kernel).astype('float32')
    kernel = 0.5 * kernel
    kernel_x = paddle.concat([kernel.unsqueeze((0, 1))] * c, axis=0)
    grad_x = F.conv2d(x, kernel_x, padding='same', groups=c)
    kernel_y = paddle.concat([kernel.t().unsqueeze((0, 1))] * c, axis=0)
    grad_y = F.conv2d(x, kernel_y, padding='same', groups=c)
    mag = paddle.sqrt(grad_x * grad_x + grad_y * grad_y + eps)
    return mag / mag.max()