class_docstr: The topology of a forest, using a split-based graph-structure representation.
  
  Parameters
  ----------
  n_labels : int
      Number of labels, the set of labels is then :math:`\{0,\dots,n-1\}`.
  partition : tuple
      A tuple of tuples that is a partition of the set :math:`\{0,\dots,n-1\}`,
      representing the label sets of each connected component of the forest topology.
  split_sets : tuple
      A tuple of tuples containing splits, where each set of splits contains only
      splits of the respective label set in the partition, so their order
      is related. The splits are the edges of the connected components of the forest,
      respectively, and thus the union of all sets of splits yields all edges of the
      forest topology.
  
  Attributes
  ----------
  where : dict
      Give the index of a split in the flattened list of all splits.
  sep : list of int
      An increasing list of numbers between 0 and m, where m is the total number
      of splits in ``self.split_sets``, starting with 0, where each number
      indicates that a new connected component starts at that index.
      Useful for example for unraveling the tuple of all splits into
      ``self.split_sets``.
  paths : list of dict
      A list of dictionaries, each dictionary is for the respective connected
      component of the forest, and the items of each dictionary are for each pair
      of labels u, v, u < v in the respective component, a list of the splits on the
      unique path between the labels u and v.
  support : list of array-like
      For each split, give an :math:`n\times n` dimensional matrix, where the
      uv-th entry is ``True`` if the split separates the labels u and v, else
      ``False``.
class_docstr_tok: ["The","topology","of","a","forest",",","using","a","split-based","graph-structure","representation",".","Parameters","--","--","--","--","--","n_labels",":","int","Number","of","labels",",","the","set","of","labels","is","then",":","math",":","`","\\","{","0",",","\\dots",",","n-1\\","}","`",".","partition",":","tuple","A","tuple","of","tuples","that","is","a","partition","of","the","set",":","math",":","`","\\","{","0",",","\\dots",",","n-1\\","}","`",",","representing","the","label","sets","of","each","connected","component","of","the","forest","topology",".","split_sets",":","tuple","A","tuple","of","tuples","containing","splits",",","where","each","set","of","splits","contains","only","splits","of","the","respective","label","set","in","the","partition",",","so","their","order","is","related",".","The","splits","are","the","edges","of","the","connected","components","of","the","forest",",","respectively",",","and","thus","the","union","of","all","sets","of","splits","yields","all","edges","of","the","forest","topology",".","Attributes","--","--","--","--","--","where",":","dict","Give","the","index","of","a","split","in","the","flattened","list","of","all","splits",".","sep",":","list","of","int","An","increasing","list","of","numbers","between","0","and","m",",","where","m","is","the","total","number","of","splits","in","``","self.split_sets","``",",","starting","with","0",",","where","each","number","indicates","that","a","new","connected","component","starts","at","that","index",".","Useful","for","example","for","unraveling","the","tuple","of","all","splits","into","``","self.split_sets","``",".","paths",":","list","of","dict","A","list","of","dictionaries",",","each","dictionary","is","for","the","respective","connected","component","of","the","forest",",","and","the","items","of","each","dictionary","are","for","each","pair","of","labels","u",",","v",",","u","<","v","in","the","respective","component",",","a","list","of","the","splits","on","the","unique","path","between","the","labels","u","and","v.","support",":","list","of","array-like","For","each","split",",","give","an",":","math",":","`","n\\times","n","`","dimensional","matrix",",","where","the","uv-th","entry","is","``","True","``","if","the","split","separates","the","labels","u","and","v",",","else","``","False","``","."]
docstr: Return a topology with partition and sets of splits of components.
code: def __init__(self, n_labels, partition, split_sets):
      """Return a topology with partition and sets of splits of components."""
      self._check_init(n_labels, partition, split_sets)
  
      self.n_labels = n_labels
      partition = [tuple(sorted(x)) for x in partition]
      seq = [part[0] for part in partition]
      sort_key = sorted(range(len(seq)), key=seq.__getitem__)
      self.partition = tuple([partition[key] for key in sort_key])
      self.split_sets = tuple(
          [tuple(sorted(split_sets[key])) for key in sort_key]
      )
  
      self.where = {
          s: i for i, s in enumerate(self.flatten(self.split_sets))
      }
  
      lengths = [len(splits) for splits in self.split_sets]
      self.sep = [0] + [
          sum(lengths[0:j]) for j in range(1, len(lengths) + 1)
      ]
  
      self.paths = [
          {
              (u, v): [s for s in splits if s.separates(u, v)]
              for u, v in itertools.combinations(part, r=2)
          }
          for part, splits in zip(self.partition, self.split_sets)
      ]
  
      _support = [
          gs.zeros((self.n_labels, self.n_labels), dtype=bool)
          for _ in self.flatten(self.split_sets)
      ]
      for path_dict in self.paths:
          for (u, v), path in path_dict.items():
              for split in path:
                  _support[self.where[split]][u][v] = True
                  _support[self.where[split]][v][u] = True
      self.support = [gs.array(m) for m in self.flatten(_support)]
      self._chart_gradient = None
  
imports: import functools
  import itertools
  import geomstats.backend
  import geomstats.geometry.spd_matrices
  from geomstats.geometry.stratified.point_set import Point, PointSet, _vectorize_point
label_desc: Use image node_id 1 to create a new Topology object  with example: obj = Topology(n_labels, partition, split_sets)