code: def generate_mask_for_feature(coor, raw_w, raw_h, mask=None):
      if mask is not None:
          assert mask.shape[0] == raw_w and mask.shape[1] == raw_h
      coor_mask = torch.zeros((raw_w, raw_h))
      # Assume it samples a point.
      if len(coor) == 2:
          # Define window size
          span = 5
          # Make sure the window does not exceed array bounds
          x_min = max(0, coor[0] - span)
          x_max = min(raw_w, coor[0] + span + 1)
          y_min = max(0, coor[1] - span)
          y_max = min(raw_h, coor[1] + span + 1)
          coor_mask[
              int(x_min) : int(x_max), int(y_min) : int(y_max)
          ] = 1
          assert (
              coor_mask == 1
          ).any(), f"coor: {coor}, raw_w: {raw_w}, raw_h: {raw_h}"
      elif len(coor) == 4:
          # Box input or Sketch input.
          coor_mask = torch.zeros((raw_w, raw_h))
          coor_mask[coor[0] : coor[2] + 1, coor[1] : coor[3] + 1] = 1
          if mask is not None:
              coor_mask = coor_mask * mask
      # coor_mask = torch.from_numpy(coor_mask)
      # pdb.set_trace()
      assert len(coor_mask.nonzero()) != 0
      return coor_mask.tolist()
  
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 1 for calling a global function with example usage: generate_mask_for_feature(coor, raw_w, raw_h, mask) and returns: coor_mask