code: def save_outputs_from_tensors(
      images,
      region_scores,
      affinity_scores,
      text_threshold,
      link_threshold,
      low_text,
      output_dir,
      image_names,
      confidence_mask=None,
  ):
      """takes images, region_scores, and affinity_scores as tensors (cab be GPU).
      :param images: 4D tensor
      :param region_scores: 3D tensor with values between 0 ~ 1
      :param affinity_scores: 3D tensor with values between 0 ~ 1
      :param text_threshold:
      :param link_threshold:
      :param low_text:
      :param output_dir: direcotry to save the output images. Will be joined with base names of image_names
      :param image_names: names of each image. Doesn't have to be the base name (image file names)
      :param confidence_mask:
      :return:
      """
      # import ipdb;ipdb.set_trace()
      # images = images.cpu().permute(0, 2, 3, 1).contiguous().data.numpy()
      if type(images) == torch.Tensor:
          images = np.array(images)
  
      region_scores = region_scores.cpu().data.numpy()
      affinity_scores = affinity_scores.cpu().data.numpy()
  
      batch_size = images.shape[0]
      assert (
          batch_size == region_scores.shape[0]
          and batch_size == affinity_scores.shape[0]
          and batch_size == len(image_names)
      ), "The first dimension (i.e. batch size) of images, region scores, and affinity scores must be equal"
  
      output_images = []
  
      for i in range(batch_size):
          image = images[i]
          region_score = region_scores[i]
          affinity_score = affinity_scores[i]
  
          image_name = os.path.basename(image_names[i])
          outoput_path = os.path.join(output_dir, image_name)
  
          output_image = save_outputs(
              image,
              region_score,
              affinity_score,
              text_threshold,
              link_threshold,
              low_text,
              outoput_path,
              confidence_mask=confidence_mask,
          )
  
          output_images.append(output_image)
  
      return output_images
  
file_path: EasyOCR/trainer/craft/utils/craft_utils.py
imports: import os
  import torch
  import cv2
  import math
  import numpy
  from data import imgproc
label_desc: Use image node_id 8 for calling a global function with example usage: save_outputs_from_tensors(images, region_scores, affinity_scores, text_threshold, link_threshold, low_text, output_dir, image_names, confidence_mask) and returns: output_images