code: def build_request(doc, ssurgeon_edits):
      request = SsurgeonRequest()
  
      for ssurgeon in ssurgeon_edits:
          ssurgeon_proto = request.ssurgeon.add()
          ssurgeon_proto.semgrex = ssurgeon.semgrex_pattern
          for operation in ssurgeon.ssurgeon_edits:
              ssurgeon_proto.operation.append(operation)
          if ssurgeon.ssurgeon_id is not None:
              ssurgeon_proto.id = ssurgeon.ssurgeon_id
          if ssurgeon.notes is not None:
              ssurgeon_proto.notes = ssurgeon.notes
          if ssurgeon.language is not None:
              ssurgeon_proto.language = ssurgeon.language
  
      try:
          for sent_idx, sentence in enumerate(doc.sentences):
              graph = request.graph.add()
              word_idx = 0
              for token in sentence.tokens:
                  for word in token.words:
                      java_protobuf_requests.add_token(
                          graph.token, word, token
                      )
                      java_protobuf_requests.add_word_to_graph(
                          graph, word, sent_idx, word_idx
                      )
  
                      word_idx = word_idx + 1
      except Exception as e:
          raise RuntimeError(
              "Failed to process sentence {}:\n{:C}".format(
                  sent_idx, sentence
              )
          ) from e
  
      return request
  
imports: import argparse
  import copy
  import os
  import re
  import sys
  from stanza.models.common.utils import misc_to_space_after, space_after_to_misc
  from stanza.protobuf import SsurgeonRequest, SsurgeonResponse
  from stanza.server import java_protobuf_requests
  from stanza.utils.conll import CoNLL
  from stanza.models.common.doc import ID, TEXT, LEMMA, UPOS, XPOS, FEATS, HEAD, DEPREL, DEPS, MISC, START_CHAR, END_CHAR, NER, Word, Token, Sentence
label_desc: Use image node_id 4 for calling a global function with example usage: build_request(doc, ssurgeon_edits) and returns: request