code: def get_shorter_decompositions(basic_decomposition):
      """Returns all arrays simpler than basic_decomposition.
  
      Returns all arrays that can be constructed from basic_decomposition
      via joining (summing) its elements.
  
      Parameters
      ----------
      basic_decomposition : list or np.array
          The array from which to build subsequent ones.
  
      Returns
      -------
      decompositions : list of tuples
          All possible arrays that can be constructed from basic_decomposition.
      counts : np.array
          counts[i] equals to the number of ways to build decompositions[i] from
          basic_decomposition.
  
      Example
      -------
      decompositions, counts = get_shorter_decompositions([1, 2, 3])
          decompositions == [(1, 5), (2, 4), (3, 3), (6,)]
          counts == [ 2.,  1.,  1.,  2.]
      """
      order = int(np.sum(basic_decomposition))
      decompositions = []
      variations = defaultdict(lambda: [])
      for curr_len in range(1, len(basic_decomposition)):
          for sum_rule in combinations_with_replacement(
              range(curr_len), order
          ):
              sum_rule = np.array(sum_rule)
              curr_pows = np.array(
                  [np.sum(sum_rule == i) for i in range(curr_len)]
              )
              curr_pows = curr_pows[curr_pows != 0]
              sorted_pow = tuple(np.sort(curr_pows))
              variations[sorted_pow].append(tuple(curr_pows))
              decompositions.append(sorted_pow)
      if len(decompositions) > 1:
          decompositions = np.unique(decompositions)
          counts = np.zeros(decompositions.shape[0])
          for i, dec in enumerate(decompositions):
              counts[i] = len(np.unique(variations[dec]))
      else:
          counts = np.ones(1)
      return decompositions, counts
  
file_path: tffm/tffm/utils.py
imports: import math
  import numpy
  import tensorflow
  import itertools
  from itertools import combinations_with_replacement, takewhile, count
  from collections import defaultdict
label_desc: Use image node_id 1 for calling a global function with example usage: get_shorter_decompositions(basic_decomposition) and returns: decompositions,  counts