def forward(self, lr_x, lr_y, hr_x):
        """
        lr_x and lr_y should be the same shape, except lr_x[1] == 1.
        The heigh and width of hr_x should be larger than lr_x and have the same channels.
        """
        mean_x = self.boxfileter(lr_x)
        mean_y = self.boxfileter(lr_y)
        cov_xy = self.boxfileter(lr_x * lr_y) - mean_x * mean_y
        var_x = self.boxfileter(lr_x * lr_x) - mean_x * mean_x
        A = cov_xy / (var_x + self.eps)
        b = mean_y - A * mean_x
        A = F.interpolate(A,
                          hr_x.shape[2:],
                          mode='bilinear',
                          align_corners=False)
        b = F.interpolate(b,
                          hr_x.shape[2:],
                          mode='bilinear',
                          align_corners=False)

        return A * hr_x + b

        lr_x and lr_y should be the same shape, except lr_x[1] == 1.
        The heigh and width of hr_x should be larger than lr_x and have the same channels.
        
Matting/ppmatting/models/layers/guided_filter.py