code: def align_face(eye_detector: Any, img: np.ndarray) -> np.ndarray:
      """
      Align a given image with the pre-built eye_detector
      Args:
          eye_detector (Any): cascade classifier object
          img (np.ndarray): given image
      Returns:
          aligned_img (np.ndarray)
      """
      # if image has unexpectedly 0 dimension then skip alignment
      if img.shape[0] == 0 or img.shape[1] == 0:
          return img
  
      detected_face_gray = cv2.cvtColor(
          img, cv2.COLOR_BGR2GRAY
      )  # eye detector expects gray scale image
  
      # eyes = eye_detector.detectMultiScale(detected_face_gray, 1.3, 5)
      eyes = eye_detector.detectMultiScale(detected_face_gray, 1.1, 10)
  
      # ----------------------------------------------------------------
  
      # opencv eye detectin module is not strong. it might find more than 2 eyes!
      # besides, it returns eyes with different order in each call (issue 435)
      # this is an important issue because opencv is the default detector and ssd also uses this
      # find the largest 2 eye. Thanks to @thelostpeace
  
      eyes = sorted(eyes, key=lambda v: abs(v[2] * v[3]), reverse=True)
  
      # ----------------------------------------------------------------
  
      if len(eyes) >= 2:
          # decide left and right eye
  
          eye_1 = eyes[0]
          eye_2 = eyes[1]
  
          if eye_1[0] < eye_2[0]:
              left_eye = eye_1
              right_eye = eye_2
          else:
              left_eye = eye_2
              right_eye = eye_1
  
          # -----------------------
          # find center of eyes
          left_eye = (
              int(left_eye[0] + (left_eye[2] / 2)),
              int(left_eye[1] + (left_eye[3] / 2)),
          )
          right_eye = (
              int(right_eye[0] + (right_eye[2] / 2)),
              int(right_eye[1] + (right_eye[3] / 2)),
          )
          img = FaceDetector.alignment_procedure(
              img, left_eye, right_eye
          )
      return img
  
file_path: deepface/deepface/detectors/OpenCvWrapper.py
imports: import os
  from typing import Any
  import cv2
  import numpy
  from deepface.detectors import FaceDetector
label_desc: Use image node_id 4 for calling a global function with example usage: align_face(eye_detector, img) and returns: img, img