code: def get_latex_batched(
      images, reformat_region_lens, texify_model, batch_size
  ):
      if len(images) == 0:
          return []
  
      predictions = [""] * len(images)
  
      for i in range(0, len(images), batch_size):
          # Dynamically set max length to save inference time
          min_idx = i
          max_idx = min(min_idx + batch_size, len(images))
          max_length = max(reformat_region_lens[min_idx:max_idx])
          max_length = min(max_length, settings.TEXIFY_MODEL_MAX)
          max_length += settings.TEXIFY_TOKEN_BUFFER
  
          model_output = batch_inference(
              images[min_idx:max_idx],
              texify_model,
              processor,
              max_tokens=max_length,
          )
  
          for j, output in enumerate(model_output):
              token_count = get_total_texify_tokens(output)
              if token_count >= max_length - 1:
                  output = ""
  
              image_idx = i + j
              predictions[image_idx] = output
      return predictions
  
imports: import io
  from copy import deepcopy
  from functools import partial
  from typing import List
  import torch
  from texify.inference import batch_inference
  from texify.model.model import load_model
  from texify.model.processor import load_processor
  import re
  from PIL import Image, ImageDraw
  from marker.bbox import should_merge_blocks, merge_boxes
  from marker.debug.data import dump_equation_debug_data
  from marker.settings import settings
  from marker.schema import Page, Span, Line, Block, BlockType
  import os
label_desc: Use image node_id 4 for calling a global function with example usage: get_latex_batched(images, reformat_region_lens, texify_model, batch_size) and returns: predictions, list