code: def __add_term_to_stats(
      self,
      term: str,
      kw_start: int,
      kw_end: int,
      embeddings: np.array,
      running_stats: CorpusRunningStats,
      subtoken_offsets: np.array,
      cat: str,
      add_to_category_embeddings: bool,
      segment: str,
      seg_start: int,
  ):
      # kw_end -= seg_start
      # kw_start -= seg_start
  
      subtoken_start = np.searchsorted(subtoken_offsets[0], kw_start)
      subtoken_end = np.searchsorted(
          subtoken_offsets[1], kw_end, side="right"
      )
      if subtoken_start == subtoken_end:
          print([f"|{t}|" for t in segment])
          print(kw_start, kw_end)
          print(
              "part",
              str(segment)[kw_start - seg_start : kw_end - seg_start],
          )
          print("term", term)
          print("subtoken start end", subtoken_start, subtoken_end)
          print(seg_start)
          print(subtoken_offsets)
          for s, e in subtoken_offsets.T:
              print(s, e, str(segment)[s - seg_start : e - seg_start])
          import pdb
  
          pdb.set_trace()
      kw_embedding = embeddings[subtoken_start:subtoken_end].mean(
          axis=0
      )
  
      if not np.isnan(kw_embedding).any():
          running_stats.add(
              term=term,
              cat=cat,
              embedding=kw_embedding,
              add_to_category_embeddings=add_to_category_embeddings,
          )
  
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 7 for calling the CorpusRunningStatsFactory obj's underlying member method code with example usage: obj.__add_term_to_stats(term, kw_start, kw_end, embeddings, running_stats, subtoken_offsets, cat, add_to_category_embeddings, segment, seg_start) without return types