def METHOD_NAME(img1,
                   img2,
                   window_size=11,
                   window=None,
                   size_average=True,
                   full=False,
                   val_range=None):
    # Value range can be different from 255. Other common ranges are 1 (sigmoid) and 2 (tanh).
    if val_range is None:
        if torch.max(img1) > 128:
            max_val = 255
        else:
            max_val = 1
        if torch.min(img1) < -0.5:
            min_val = -1
        else:
            min_val = 0
        L = max_val - min_val
    else:
        L = val_range
    padd = 0
    (_, _, height, width) = img1.size()
    if window is None:
        real_size = min(window_size, height, width)
        window = create_window_3d(
            real_size, channel=1, device=img1.device).to(img1.device)
        # Channel is set to 1 since we consider color images as volumetric images
    img1 = img1.unsqueeze(1)
    img2 = img2.unsqueeze(1)
    mu1 = F.conv3d(
        F.pad(img1, (5, 5, 5, 5, 5, 5), mode='replicate'),
        window,
        padding=padd,
        groups=1)
    mu2 = F.conv3d(
        F.pad(img2, (5, 5, 5, 5, 5, 5), mode='replicate'),
        window,
        padding=padd,
        groups=1)
    mu1_sq = mu1.pow(2)
    mu2_sq = mu2.pow(2)
    mu1_mu2 = mu1 * mu2
    sigma1_sq = F.conv3d(
        F.pad(img1 * img1, (5, 5, 5, 5, 5, 5), 'replicate'),
        window,
        padding=padd,
        groups=1) - mu1_sq
    sigma2_sq = F.conv3d(
        F.pad(img2 * img2, (5, 5, 5, 5, 5, 5), 'replicate'),
        window,
        padding=padd,
        groups=1) - mu2_sq
    sigma12 = F.conv3d(
        F.pad(img1 * img2, (5, 5, 5, 5, 5, 5), 'replicate'),
        window,
        padding=padd,
        groups=1) - mu1_mu2
    C1 = (0.01 * L)**2
    C2 = (0.03 * L)**2
    v1 = 2.0 * sigma12 + C2
    v2 = sigma1_sq + sigma2_sq + C2
    cs = torch.mean(v1 / v2)  # contrast sensitivity
    ssim_map = ((2 * mu1_mu2 + C1) * v1) / ((mu1_sq + mu2_sq + C1) * v2)
    if size_average:
        ret = ssim_map.mean()
    else:
        ret = ssim_map.mean(1).mean(1).mean(1)
    if full:
        return ret, cs
    return ret.cpu()