code: def test_net(
      canvas_size,
      mag_ratio,
      net,
      image,
      text_threshold,
      link_threshold,
      low_text,
      poly,
      device,
      estimate_num_chars=False,
  ):
      if (
          isinstance(image, np.ndarray) and len(image.shape) == 4
      ):  # image is batch of np arrays
          image_arrs = image
      else:  # image is single numpy array
          image_arrs = [image]
  
      img_resized_list = []
      # resize
      for img in image_arrs:
          img_resized, target_ratio, size_heatmap = resize_aspect_ratio(
              img,
              canvas_size,
              interpolation=cv2.INTER_LINEAR,
              mag_ratio=mag_ratio,
          )
          img_resized_list.append(img_resized)
      ratio_h = ratio_w = 1 / target_ratio
      # preprocessing
      x = [
          np.transpose(normalizeMeanVariance(n_img), (2, 0, 1))
          for n_img in img_resized_list
      ]
      x = torch.from_numpy(np.array(x))
      x = x.to(device)
  
      # forward pass
      with torch.no_grad():
          y, feature = net(x)
  
      boxes_list, polys_list = [], []
      for out in y:
          # make score and link map
          score_text = out[:, :, 0].cpu().data.numpy()
          score_link = out[:, :, 1].cpu().data.numpy()
  
          # Post-processing
          boxes, polys, mapper = getDetBoxes(
              score_text,
              score_link,
              text_threshold,
              link_threshold,
              low_text,
              poly,
              estimate_num_chars,
          )
  
          # coordinate adjustment
          boxes = adjustResultCoordinates(boxes, ratio_w, ratio_h)
          polys = adjustResultCoordinates(polys, ratio_w, ratio_h)
          if estimate_num_chars:
              boxes = list(boxes)
              polys = list(polys)
          for k in range(len(polys)):
              if estimate_num_chars:
                  boxes[k] = (boxes[k], mapper[k])
              if polys[k] is None:
                  polys[k] = boxes[k]
          boxes_list.append(boxes)
          polys_list.append(polys)
  
      return boxes_list, polys_list
  
file_path: EasyOCR/easyocr/detection.py
imports: import torch
  import torch.backends.cudnn
  from torch.autograd import Variable
  from PIL import Image
  from collections import OrderedDict
  import cv2
  import numpy
  from .craft_utils import getDetBoxes, adjustResultCoordinates
  from .imgproc import resize_aspect_ratio, normalizeMeanVariance
  from .craft import CRAFT
label_desc: Use image node_id 2 for calling a global function with example usage: test_net(canvas_size, mag_ratio, net, image, text_threshold, link_threshold, low_text, poly, device, estimate_num_chars) and returns: boxes_list,  polys_list