code: def resize_norm_img(self, img, max_wh_ratio):
      imgC, imgH, imgW = self.rec_image_shape
      if self.rec_algorithm == "NRTR" or self.rec_algorithm == "ViTSTR":
          img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
          # return padding_im
          image_pil = Image.fromarray(np.uint8(img))
          if self.rec_algorithm == "ViTSTR":
              img = image_pil.resize([imgW, imgH], Image.BICUBIC)
          else:
              img = image_pil.resize([imgW, imgH], Image.LANCZOS)
          img = np.array(img)
          norm_img = np.expand_dims(img, -1)
          norm_img = norm_img.transpose((2, 0, 1))
          if self.rec_algorithm == "ViTSTR":
              norm_img = norm_img.astype(np.float32) / 255.0
          else:
              norm_img = norm_img.astype(np.float32) / 128.0 - 1.0
          return norm_img
      elif self.rec_algorithm == "RFL":
          img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
          resized_image = cv2.resize(
              img, (imgW, imgH), interpolation=cv2.INTER_CUBIC
          )
          resized_image = resized_image.astype("float32")
          resized_image = resized_image / 255
          resized_image = resized_image[np.newaxis, :]
          resized_image -= 0.5
          resized_image /= 0.5
          return resized_image
  
      assert imgC == img.shape[2]
      imgW = int((imgH * max_wh_ratio))
      if self.use_onnx:
          w = self.input_tensor.shape[3:][0]
          if isinstance(w, str):
              pass
          elif w is not None and w > 0:
              imgW = w
      h, w = img.shape[:2]
      ratio = w / float(h)
      if math.ceil(imgH * ratio) > imgW:
          resized_w = imgW
      else:
          resized_w = int(math.ceil(imgH * ratio))
      if self.rec_algorithm == "RARE":
          if resized_w > self.rec_image_shape[2]:
              resized_w = self.rec_image_shape[2]
          imgW = self.rec_image_shape[2]
      resized_image = cv2.resize(img, (resized_w, imgH))
      resized_image = resized_image.astype("float32")
      resized_image = resized_image.transpose((2, 0, 1)) / 255
      resized_image -= 0.5
      resized_image /= 0.5
      padding_im = np.zeros((imgC, imgH, imgW), dtype=np.float32)
      padding_im[:, :, 0:resized_w] = resized_image
      return padding_im
  
imports: import os
  import sys
  from PIL import Image
  import cv2
  import numpy
  import math
  import time
  import traceback
  import paddle
  import tools.infer.utility
  from ppocr.postprocess import build_post_process
  from ppocr.utils.logging import get_logger
  from ppocr.utils.utility import get_image_file_list, check_and_read
label_desc: Use image node_id 2 for calling the TextRecognizer obj's underlying member method code with example usage: obj.resize_norm_img(img, max_wh_ratio) and returns: padding_im, norm_img, resized_image