code: def calculate_psnr(img1, img2, mask):
      # img1 and img2 have range [0, 1]
      img1 = img1.astype(np.float64)
      img2 = img2.astype(np.float64)
      mse = (
          np.mean((img1 - img2) ** 2)
          * (img2.shape[0] * img2.shape[1])
          / mask.sum()
      )
      if mse == 0:
          return float("inf")
      return 20 * math.log10(1.0 / math.sqrt(mse))
  
file_path: insightface/reconstruction/PBIDR/code/evaluation/eval.py
imports: import sys
  import argparse
  import GPUtil
  import os
  from pyhocon import ConfigFactory
  import torch
  import numpy
  import cvxpy
  from PIL import Image
  import math
  import utils.general
  import utils.plots
  from utils import rend_util
label_desc: Use image node_id 2 for calling a global function with example usage: calculate_psnr(img1, img2, mask) and returns: unknown, float