code: def store_text_prediction(self, prediction, sample_id, output_dir):
      sentence = prediction.sentence
      sample = self.sample_by_id(sample_id)
      ns = sample["ns"]
      line = sample["xml_element"]
      textequivxml = line.find(
          './ns:TextEquiv[@index="{}"]'.format(self.params.text_index),
          namespaces=ns,
      )
      if textequivxml is None:
          textequivxml = etree.SubElement(
              line,
              "TextEquiv",
              attrib={"index": str(self.params.text_index)},
          )
  
      u_xml = textequivxml.find("./ns:Unicode", namespaces=ns)
      if u_xml is None:
          u_xml = etree.SubElement(textequivxml, "Unicode")
  
      u_xml.text = sentence
  
      if self.params.output_glyphs:
          words = self._words_from_prediction(prediction)
  
          # delete or rename old words before writing the new ones
          self._store_old_words(line, ns)
          self._store_words(
              words, line, self._parse_coords(sample["coords"]), ns
          )
  
      if self.params.output_confidences:
          textequivxml.set("conf", str(prediction.avg_char_probability))
  
      # check if page can be stored, this requires that (standard in prediction) the pages are passed sequentially
      if self._last_page_id != sample["page_id"]:
          if self._last_page_id:
              self._store_page(
                  self.params.pred_extension, self._last_page_id
              )
          self._last_page_id = sample["page_id"]
  
imports: import os
  from copy import deepcopy
  from dataclasses import dataclass, field
  from random import shuffle
  import math
  import numpy
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.data.pipeline.definitions import PipelineMode, INPUT_PROCESSOR, TARGETS_PROCESSOR
  from tqdm import tqdm
  from lxml import etree
  import cv2
  from typing import List, Generator, Optional, Iterable, Dict, Any, Tuple
  from enum import IntEnum
  from calamari_ocr.ocr.dataset.datareader.base import CalamariDataGenerator, CalamariDataGeneratorParams, InputSample, SampleMeta
  from calamari_ocr.utils import split_all_ext, filename, glob_all
  from calamari_ocr.ocr.predict.params import Prediction
  import logging
label_desc: Use image node_id 4 for calling the PageXMLReader obj's underlying member method code with example usage: obj.store_text_prediction(prediction, sample_id, output_dir) without return types