code: def build_enhancer_request(doc, language, pronouns_pattern):
      if bool(language) == bool(pronouns_pattern):
          raise ValueError(
              "Should set exactly one of language and pronouns_pattern"
          )
  
      request = DependencyEnhancerRequest()
      if pronouns_pattern:
          request.setRelativePronouns(pronouns_pattern)
      elif language.lower() in ("en", "english"):
          request.language = Language.UniversalEnglish
      elif language.lower() in ("zh", "zh-hans", "chinese"):
          request.language = Language.UniversalChinese
      else:
          raise ValueError(
              "Sorry, but language "
              + language
              + " is not supported yet.  Either set a pronouns pattern or file an issue at https://stanfordnlp.github.io/stanza suggesting a mechanism for converting this language"
          )
  
      request_doc = request.document
      request_doc.text = doc.text
      num_tokens = 0
      for sent_idx, sentence in enumerate(doc.sentences):
          request_sentence = add_sentence(
              request_doc.sentence, sentence, num_tokens
          )
          num_tokens = num_tokens + sum(
              len(token.words) for token in sentence.tokens
          )
  
          graph = request_sentence.basicDependencies
          nodes = []
          word_index = 0
          for token in sentence.tokens:
              for word in token.words:
                  # TODO: refactor with the bit in java_protobuf_requests
                  word_index = word_index + 1
                  node = graph.node.add()
                  node.sentenceIndex = sent_idx
                  node.index = word_index
  
                  if word.head != 0:
                      edge = graph.edge.add()
                      edge.source = word.head
                      edge.target = word_index
                      edge.dep = word.deprel
  
      return request
  
file_path: stanza/stanza/server/ud_enhancer.py
imports: import stanza
  from stanza.protobuf import DependencyEnhancerRequest, Document, Language
  from stanza.server.java_protobuf_requests import send_request, add_sentence, JavaProtobufContext
label_desc: Use image node_id 1 for calling a global function with example usage: build_enhancer_request(doc, language, pronouns_pattern) and returns: request