code: def format_region_prompt(prompt, refer_input_state):
      # Find regions in prompts and assign corresponding region masks
      refer_input_state["region_masks_in_prompts"] = []
      indices_region_placeholder_in_prompt = find_indices_in_order(
          refer_input_state["region_placeholder_tokens"], prompt
      )
      refer_input_state["region_masks_in_prompts"] = [
          refer_input_state["region_masks"][iii]
          for iii in indices_region_placeholder_in_prompt
      ]
  
      # Find regions in prompts and replace with real coordinates and region feature token.
      for region_ph_index, region_ph_i in enumerate(
          refer_input_state["region_placeholder_tokens"]
      ):
          prompt = prompt.replace(
              region_ph_i,
              "{} {}".format(
                  refer_input_state["region_coordinates"][
                      region_ph_index
                  ],
                  DEFAULT_REGION_FEA_TOKEN,
              ),
          )
      return prompt
  
imports: import argparse
  import datetime
  import json
  import os
  import time
  import gradio
  import requests
  from ferret.conversation import default_conversation, conv_templates, SeparatorStyle
  from ferret.constants import LOGDIR
  from ferret.utils import build_logger, server_error_msg, violates_moderation, moderation_msg
  import hashlib
  import re
  from copy import deepcopy
  from PIL import ImageDraw, ImageFont
  from gradio import processing_utils
  import numpy
  import torch
  import torch.nn.functional
  from scipy.ndimage import binary_dilation, binary_erosion
  import pdb
  from ferret.serve.gradio_css import code_highlight_css
label_desc: Use image node_id 18 for calling a global function with example usage: format_region_prompt(prompt, refer_input_state) and returns: prompt