code: def test_coref_chain(doc_pb):
      """
      Extract the corefence chains from the annotation.
      """
      # Coreference chains span sentences and are stored in the
      # document.
      chains = doc_pb.corefChain
  
      # In this document there is 1 chain with Chris and he.
      assert len(chains) == 1
      chain = chains[0]
      assert isinstance(chain, CorefChain)
      assert chain.mention[0].beginIndex == 0  # 'Chris'
      assert chain.mention[0].endIndex == 1
      assert chain.mention[0].gender == "MALE"
  
      assert chain.mention[1].beginIndex == 6  # 'he'
      assert chain.mention[1].endIndex == 7
      assert chain.mention[1].gender == "MALE"
  
      assert chain.representative == 0
  
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 8 for calling a global function with example usage: test_coref_chain(doc_pb) without return types