code: def write_conll(doc: Doc, clusters: List[List[Span]], f_obj: TextIO):
      """Writes span/cluster information to f_obj, which is assumed to be a file
      object open for writing"""
      placeholder = "  -" * 7
      doc_id = doc["document_id"]
      words = doc["cased_words"]
      part_id = doc["part_id"]
      sents = doc["sent_id"]
  
      max_word_len = max(len(w) for w in words)
  
      starts = defaultdict(lambda: [])
      ends = defaultdict(lambda: [])
      single_word = defaultdict(lambda: [])
  
      for cluster_id, cluster in enumerate(clusters):
          for start, end in cluster:
              if end - start == 1:
                  single_word[start].append(cluster_id)
              else:
                  starts[start].append(cluster_id)
                  ends[end - 1].append(cluster_id)
  
      f_obj.write(f"#begin document ({doc_id}); part {part_id:0>3d}\n")
  
      word_number = 0
      for word_id, word in enumerate(words):
          cluster_info_lst = []
          for cluster_marker in starts[word_id]:
              cluster_info_lst.append(f"({cluster_marker}")
          for cluster_marker in single_word[word_id]:
              cluster_info_lst.append(f"({cluster_marker})")
          for cluster_marker in ends[word_id]:
              cluster_info_lst.append(f"{cluster_marker})")
          cluster_info = (
              "|".join(cluster_info_lst) if cluster_info_lst else "-"
          )
  
          if word_id == 0 or sents[word_id] != sents[word_id - 1]:
              f_obj.write("\n")
              word_number = 0
  
          f_obj.write(
              f"{doc_id}  {part_id}  {word_number:>2}"
              f"  {word:>{max_word_len}}{placeholder}  {cluster_info}\n"
          )
  
          word_number += 1
  
      f_obj.write("#end document\n\n")
  
imports: from collections import defaultdict
  from contextlib import contextmanager
  import os
  from typing import List, TextIO
  from stanza.models.coref.config import Config
  from stanza.models.coref.const import Doc, Span
label_desc: Use image node_id 1 for calling a global function with example usage: write_conll(doc, clusters, f_obj) without return types