code: def verify(
      img1_path: Union[str, np.ndarray],
      img2_path: Union[str, np.ndarray],
      model_name: str = "VGG-Face",
      detector_backend: str = "opencv",
      distance_metric: str = "cosine",
      enforce_detection: bool = True,
      align: bool = True,
      normalization: str = "base",
  ) -> Dict[str, Any]:
      """
      This function verifies an image pair is same person or different persons. In the background,
      verification function represents facial images as vectors and then calculates the similarity
      between those vectors. Vectors of same person images should have more similarity (or less
      distance) than vectors of different persons.
  
      Parameters:
              img1_path, img2_path: exact image path as string. numpy array (BGR) or based64 encoded
              images are also welcome. If one of pair has more than one face, then we will compare the
              face pair with max similarity.
  
              model_name (str): VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepID, Dlib
              , ArcFace and SFace
  
              distance_metric (string): cosine, euclidean, euclidean_l2
  
              enforce_detection (boolean): If no face could not be detected in an image, then this
              function will return exception by default. Set this to False not to have this exception.
              This might be convenient for low resolution images.
  
              detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd,
              dlib, mediapipe or yolov8.
  
              align (boolean): alignment according to the eye positions.
  
              normalization (string): normalize the input image before feeding to model
  
      Returns:
              Verify function returns a dictionary.
  
              {
                      "verified": True
                      , "distance": 0.2563
                      , "max_threshold_to_verify": 0.40
                      , "model": "VGG-Face"
                      , "similarity_metric": "cosine"
                      , 'facial_areas': {
                              'img1': {'x': 345, 'y': 211, 'w': 769, 'h': 769},
                              'img2': {'x': 318, 'y': 534, 'w': 779, 'h': 779}
                      }
                      , "time": 2
              }
  
      """
  
      tic = time.time()
  
      # --------------------------------
      target_size = functions.find_target_size(model_name=model_name)
  
      # img pairs might have many faces
      img1_objs = functions.extract_faces(
          img=img1_path,
          target_size=target_size,
          detector_backend=detector_backend,
          grayscale=False,
          enforce_detection=enforce_detection,
          align=align,
      )
  
      img2_objs = functions.extract_faces(
          img=img2_path,
          target_size=target_size,
          detector_backend=detector_backend,
          grayscale=False,
          enforce_detection=enforce_detection,
          align=align,
      )
      # --------------------------------
      distances = []
      regions = []
      # now we will find the face pair with minimum distance
      for img1_content, img1_region, _ in img1_objs:
          for img2_content, img2_region, _ in img2_objs:
              img1_embedding_obj = representation.represent(
                  img_path=img1_content,
                  model_name=model_name,
                  enforce_detection=enforce_detection,
                  detector_backend="skip",
                  align=align,
                  normalization=normalization,
              )
  
              img2_embedding_obj = representation.represent(
                  img_path=img2_content,
                  model_name=model_name,
                  enforce_detection=enforce_detection,
                  detector_backend="skip",
                  align=align,
                  normalization=normalization,
              )
  
              img1_representation = img1_embedding_obj[0]["embedding"]
              img2_representation = img2_embedding_obj[0]["embedding"]
  
              if distance_metric == "cosine":
                  distance = dst.findCosineDistance(
                      img1_representation, img2_representation
                  )
              elif distance_metric == "euclidean":
                  distance = dst.findEuclideanDistance(
                      img1_representation, img2_representation
                  )
              elif distance_metric == "euclidean_l2":
                  distance = dst.findEuclideanDistance(
                      dst.l2_normalize(img1_representation),
                      dst.l2_normalize(img2_representation),
                  )
              else:
                  raise ValueError(
                      "Invalid distance_metric passed - ",
                      distance_metric,
                  )
  
              distances.append(distance)
              regions.append((img1_region, img2_region))
  
      # -------------------------------
      threshold = dst.findThreshold(model_name, distance_metric)
      distance = min(distances)  # best distance
      facial_areas = regions[np.argmin(distances)]
  
      toc = time.time()
  
      # pylint: disable=simplifiable-if-expression
      resp_obj = {
          "verified": True if distance <= threshold else False,
          "distance": distance,
          "threshold": threshold,
          "model": model_name,
          "detector_backend": detector_backend,
          "similarity_metric": distance_metric,
          "facial_areas": {
              "img1": facial_areas[0],
              "img2": facial_areas[1],
          },
          "time": round(toc - tic, 2),
      }
  
      return resp_obj
  
imports: import time
  from typing import Any, Dict, Union
  import numpy
  from deepface.commons import functions, distance
  from deepface.modules import representation
label_desc: Use image node_id 1 for calling a global function with example usage: verify(img1_path, img2_path, model_name, detector_backend, distance_metric, enforce_detection, align, normalization) and returns: resp_obj