code: def all_partitions(indices):
      
      n = len(indices)
      partitions = _partitions_list(n)
      if n > 0:
          partitions[-1] = [list(range(n))]
  
      for partition in partitions:
          yield tuple(tuple(indices[i] for i in part)
                      for part in partition)
docs: Return a list of all possible coarse grains of a network.
  
      Args:
          indices (tuple[int]): The micro indices to partition.
  
      Yields:
          tuple[tuple]: A possible partition. Each element of the tuple
          is a tuple of micro-elements which correspond to macro-elements.