code: def test_dependency_parse(doc_pb):
      """
      Extract the dependency parse from the annotation.
      """
      sentence = doc_pb.sentence[0]
  
      # You can choose from the following types of dependencies.
      # In general, you'll want enhancedPlusPlus
      assert sentence.basicDependencies.ByteSize() > 0
      assert sentence.enhancedDependencies.ByteSize() > 0
      assert sentence.enhancedPlusPlusDependencies.ByteSize() > 0
  
      tree = sentence.enhancedPlusPlusDependencies
      isinstance(tree, DependencyGraph)
      # Indices are 1-indexd with 0 being the "pseudo root"
      assert tree.root  # 'wrote' is the root. == [2]
      # There are as many nodes as there are tokens.
      assert len(tree.node) == len(sentence.token)
  
      # Enhanced++ dependencies often contain additional edges and are
      # not trees -- here, 'parsed' would also have an edge to
      # 'sentence'
      assert len(tree.edge) == 12
  
      # This edge goes from "wrote" to "Chirs"
      edge = tree.edge[0]
      assert edge.source == 2
      assert edge.target == 1
      assert edge.dep == "nsubj"
  
file_path: stanza/stanza/tests/server/test_protobuf.py
imports: import os
  from pathlib import Path
  import pytest
  from pytest import fixture
  from stanza.protobuf import Document, Sentence, Token, DependencyGraph, CorefChain
  from stanza.protobuf import parseFromDelimitedString, writeToDelimitedString, to_text
label_desc: Use image node_id 7 for calling a global function with example usage: test_dependency_parse(doc_pb) without return types