code: def merge_small_sections_of_texts(texts_in_secs, min_num_texts):
      """
      Merge sections that are too small, i.e. have too few "content" which means that their number
      of texts is lower than or equal <min_num_texts>.
  
      Return merged sections.
      """
      merged_secs = []
      prev_sec = None
      for cur_sec in texts_in_secs:
          if prev_sec:
              if (
                  len(cur_sec) <= min_num_texts
              ):  # number of texts is too low
                  sec = (
                      cur_sec + prev_sec
                  )  # merge this section with the previous section
                  if (
                      len(merged_secs) > 0
                  ):  # remove the prev. section from the final list
                      merged_secs.pop()  # in order to add the merged section later
              else:
                  sec = cur_sec
          else:
              sec = cur_sec
  
          merged_secs.append(sec)  # add the (possibly merged) section
          prev_sec = sec
  
      assert len(flatten_list(texts_in_secs)) == len(
          flatten_list(merged_secs)
      )
  
      return merged_secs
  
file_path: pdftabextract/pdftabextract/clustering.py
imports: import itertools
  import numpy
  from scipy.stats import chisquare
  from pdftabextract import logger
  from pdftabextract.common import fill_array_a_with_values_from_b, sorted_by_attr, flatten_list, update_text_dict_dim, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL
label_desc: Use image node_id 6 for calling a global function with example usage: merge_small_sections_of_texts(texts_in_secs, min_num_texts) and returns: merged_secs