docs: def encode_annotation(annotation):
      """Encode a single annotation."""
      tree = etree.Element('annotation', {'id': annotation.id})
      encode_infons(tree, annotation.infons)
      for location in annotation.locations:
          tree.append(encode_location(location))
      etree.SubElement(tree, 'text').text = annotation.text
      return tree