code: def find(
      img_path: Union[str, np.ndarray],
      db_path: str,
      model_name: str = "VGG-Face",
      distance_metric: str = "cosine",
      enforce_detection: bool = True,
      detector_backend: str = "opencv",
      align: bool = True,
      normalization: str = "base",
      silent: bool = False,
  ) -> List[pd.DataFrame]:
      """
      This function applies verification several times and find the identities in a database
  
      Parameters:
              img_path: exact image path, numpy array (BGR) or based64 encoded image.
              Source image can have many faces. Then, result will be the size of number of
              faces in the source image.
  
              db_path (string): You should store some image files in a folder and pass the
              exact folder path to this. A database image can also have many faces.
              Then, all detected faces in db side will be considered in the decision.
  
              model_name (string): VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepID,
              Dlib, ArcFace, SFace or Ensemble
  
              distance_metric (string): cosine, euclidean, euclidean_l2
  
              enforce_detection (bool): The function throws exception if a face could not be detected.
              Set this to False if you don't want to get 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
  
              silent (boolean): disable some logging and progress bars
  
      Returns:
              This function returns list of pandas data frame. Each item of the list corresponding to
              an identity in the img_path.
      """
  
      tic = time.time()
  
      # -------------------------------
      if os.path.isdir(db_path) is not True:
          raise ValueError("Passed db_path does not exist!")
  
      target_size = functions.find_target_size(model_name=model_name)
  
      # ---------------------------------------
  
      file_name = f"representations_{model_name}.pkl"
      file_name = file_name.replace("-", "_").lower()
      datastore_path = f"{db_path}/{file_name}"
  
      df_cols = [
          "identity",
          f"{model_name}_representation",
          "target_x",
          "target_y",
          "target_w",
          "target_h",
      ]
  
      if os.path.exists(datastore_path):
          with open(datastore_path, "rb") as f:
              representations = pickle.load(f)
  
              if len(representations) > 0 and len(
                  representations[0]
              ) != len(df_cols):
                  raise ValueError(
                      f"Seems existing {datastore_path} is out-of-the-date."
                      "Please delete it and re-run."
                  )
  
          alpha_employees = __list_images(path=db_path)
          beta_employees = [
              representation[0] for representation in representations
          ]
  
          newbies = list(set(alpha_employees) - set(beta_employees))
          oldies = list(set(beta_employees) - set(alpha_employees))
  
          if newbies:
              logger.warn(
                  f"Items {newbies} were added into {db_path}"
                  f" just after data source {datastore_path} created!"
              )
              newbies_representations = __find_bulk_embeddings(
                  employees=newbies,
                  model_name=model_name,
                  target_size=target_size,
                  detector_backend=detector_backend,
                  enforce_detection=enforce_detection,
                  align=align,
                  normalization=normalization,
                  silent=silent,
              )
              representations = (
                  representations + newbies_representations
              )
  
          if oldies:
              logger.warn(
                  f"Items {oldies} were dropped from {db_path}"
                  f" just after data source {datastore_path} created!"
              )
              representations = [
                  rep for rep in representations if rep[0] not in oldies
              ]
  
          if newbies or oldies:
              if len(representations) == 0:
                  raise ValueError(
                      f"There is no image in {db_path} anymore!"
                  )
  
              # save new representations
              with open(datastore_path, "wb") as f:
                  pickle.dump(representations, f)
  
              if not silent:
                  logger.info(
                      f"{len(newbies)} new representations are just added"
                      f" whereas {len(oldies)} represented one(s) are just dropped"
                      f" in {db_path}/{file_name} file."
                  )
  
          if not silent:
              logger.info(
                  f"There are {len(representations)} representations found in {file_name}"
              )
  
      else:  # create representation.pkl from scratch
          employees = __list_images(path=db_path)
  
          if len(employees) == 0:
              raise ValueError(
                  f"There is no image in {db_path} folder!"
                  "Validate .jpg, .jpeg or .png files exist in this path.",
              )
  
          # ------------------------
          # find representations for db images
          representations = __find_bulk_embeddings(
              employees=employees,
              model_name=model_name,
              target_size=target_size,
              detector_backend=detector_backend,
              enforce_detection=enforce_detection,
              align=align,
              normalization=normalization,
              silent=silent,
          )
  
          # -------------------------------
  
          with open(datastore_path, "wb") as f:
              pickle.dump(representations, f)
  
          if not silent:
              logger.info(
                  f"Representations stored in {db_path}/{file_name} file."
              )
  
      # ----------------------------
      # now, we got representations for facial database
      df = pd.DataFrame(
          representations,
          columns=df_cols,
      )
  
      # img path might have more than once face
      source_objs = functions.extract_faces(
          img=img_path,
          target_size=target_size,
          detector_backend=detector_backend,
          grayscale=False,
          enforce_detection=enforce_detection,
          align=align,
      )
  
      resp_obj = []
  
      for source_img, source_region, _ in source_objs:
          target_embedding_obj = representation.represent(
              img_path=source_img,
              model_name=model_name,
              enforce_detection=enforce_detection,
              detector_backend="skip",
              align=align,
              normalization=normalization,
          )
  
          target_representation = target_embedding_obj[0]["embedding"]
  
          result_df = df.copy()  # df will be filtered in each img
          result_df["source_x"] = source_region["x"]
          result_df["source_y"] = source_region["y"]
          result_df["source_w"] = source_region["w"]
          result_df["source_h"] = source_region["h"]
  
          distances = []
          for _, instance in df.iterrows():
              source_representation = instance[
                  f"{model_name}_representation"
              ]
  
              target_dims = len(list(target_representation))
              source_dims = len(list(source_representation))
              if target_dims != source_dims:
                  raise ValueError(
                      "Source and target embeddings must have same dimensions but "
                      + f"{target_dims}:{source_dims}. Model structure may change"
                      + " after pickle created. Delete the {file_name} and re-run."
                  )
  
              if distance_metric == "cosine":
                  distance = dst.findCosineDistance(
                      source_representation, target_representation
                  )
              elif distance_metric == "euclidean":
                  distance = dst.findEuclideanDistance(
                      source_representation, target_representation
                  )
              elif distance_metric == "euclidean_l2":
                  distance = dst.findEuclideanDistance(
                      dst.l2_normalize(source_representation),
                      dst.l2_normalize(target_representation),
                  )
              else:
                  raise ValueError(
                      f"invalid distance metric passes - {distance_metric}"
                  )
  
              distances.append(distance)
  
              # ---------------------------
  
          result_df[f"{model_name}_{distance_metric}"] = distances
  
          threshold = dst.findThreshold(model_name, distance_metric)
          result_df = result_df.drop(
              columns=[f"{model_name}_representation"]
          )
          # pylint: disable=unsubscriptable-object
          result_df = result_df[
              result_df[f"{model_name}_{distance_metric}"] <= threshold
          ]
          result_df = result_df.sort_values(
              by=[f"{model_name}_{distance_metric}"], ascending=True
          ).reset_index(drop=True)
  
          resp_obj.append(result_df)
  
      # -----------------------------------
  
      toc = time.time()
  
      if not silent:
          logger.info(f"find function lasts {toc - tic} seconds")
  
      return resp_obj
  
file_path: deepface/deepface/modules/recognition.py
imports: import os
  import pickle
  from typing import List, Union
  import time
  import numpy
  import pandas
  from tqdm import tqdm
  from deepface.commons import functions, distance
  from deepface.commons.logger import Logger
  from deepface.modules import representation
label_desc: Use image node_id 1 for calling a global function with example usage: find(img_path, db_path, model_name, distance_metric, enforce_detection, detector_backend, align, normalization, silent) and returns: resp_obj