code: def add_text(
      state,
      text,
      image_process_mode,
      original_image,
      sketch_pad,
      request: gr.Request,
  ):
      image = sketch_pad["image"]
  
      logger.info(
          f"add_text. ip: {request.client.host}. len: {len(text)}"
      )
      if len(text) <= 0 and image is None:
          state.skip_next = True
          return (state, state.to_gradio_chatbot(), "", None) + (
              no_change_btn,
          ) * 5
      if args.moderate:
          flagged = violates_moderation(text)
          if flagged:
              state.skip_next = True
              return (
                  state,
                  state.to_gradio_chatbot(),
                  moderation_msg,
                  None,
              ) + (no_change_btn,) * 5
  
      text = text[:1536]  # Hard cut-off
      if original_image is None:
          assert image is not None
          original_image = image.copy()
          print("No location, copy original image in add_text")
  
      if image is not None:
          if state.first_round:
              text = text[:1200]  # Hard cut-off for images
              if "<image>" not in text:
                  # text = '<Image><image></Image>' + text
                  text = text + "\n<image>"
              text = (text, original_image, image_process_mode)
              if len(state.get_images(return_pil=True)) > 0:
                  new_state = default_conversation.copy()
                  new_state.first_round = False
                  state = new_state
                  print("First round add image finsihed.")
  
      state.append_message(state.roles[0], text)
      state.append_message(state.roles[1], None)
      state.skip_next = False
      return (state, state.to_gradio_chatbot(), "", original_image) + (
          disable_btn,
      ) * 5
  
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 15 for calling a global function with example usage: add_text(state, text, image_process_mode, original_image, sketch_pad, request) and returns: unknown, unknown, unknown