code: def _add_offsets_to_running_stats(
      self, doc_idx, doc, cat, running_stats, offset_df
  ) -> None:
      doc_offset_df = self.__query_for_doc_offset_df(offset_df, doc_idx)
      if len(doc_offset_df):
          for segment in self.doc_segmenter(doc):
              # keywords = self.term_keyword_processor.extract_keywords(str(segment), span_info=True)
              # if keywords:
  
              seg_start = segment[0].idx
              seg_end = seg_start + len(str(segment))
              try:
                  annots = doc_offset_df[
                      lambda df: (df.Start >= seg_start)
                      & (df.End <= seg_end)
                  ]
              except:
                  print("!!!")
                  print(doc_offset_df)
                  print(seg_start, seg_end)
                  print(
                      (doc_offset_df.Start >= seg_start)
                      & (doc_offset_df.End <= seg_end)
                  )
                  mask = (doc_offset_df.Start >= seg_start) & (
                      doc_offset_df.End <= seg_end
                  )
                  import pdb
  
                  pdb.set_trace()
  
              embeddings = None
              if len(annots):
                  embeddings, subtoken_offsets = self.__embed_segment(
                      segment, seg_start
                  )
                  annots.apply(
                      lambda r: self.__add_term_to_stats(
                          term=self.corpus.get_metadata_from_index(
                              r.TermIdx
                          ),
                          kw_start=r.Start,
                          kw_end=r.End,
                          embeddings=embeddings,
                          running_stats=running_stats,
                          subtoken_offsets=subtoken_offsets,
                          cat=cat,
                          add_to_category_embeddings=not self.use_all_tokens_for_category_embeddings,
                          segment=segment,
                          seg_start=seg_start,
                      ),
                      axis=1,
                  )
  
              if self.use_all_tokens_for_category_embeddings:
                  if embeddings is None:
                      embeddings, _ = self.__embed_segment(
                          segment, seg_start, adjust_offsets=False
                      )
                  running_stats.add_embeddings_to_category(
                      embeddings=embeddings, cat=cat
                  )
  
imports: import dataclasses
  from typing import Iterable, Optional, Callable, Union
  import flashtext
  import numpy
  import spacy
  import pandas
  from scattertext.contextual_embeddings.doc_splitter import doc_sentence_splitter
  from scattertext.features.FeatsFromSpacyDoc import FeatsFromSpacyDoc
  from scattertext.OffsetCorpus import OffsetCorpus
  from tqdm.auto import tqdm
  from scattertext.ParsedCorpus import ParsedCorpus
  from scattertext.contextual_embeddings.corpus_runing_stats import CorpusRunningStats
label_desc: Use image node_id 4 for calling the CorpusRunningStatsFactory obj's underlying member method code with example usage: obj._add_offsets_to_running_stats(doc_idx, doc, cat, running_stats, offset_df) without return types