code: def powers_and_coefs(order):
      """For a `order`-way FM returns the powers and their coefficients needed to
      compute model equation efficiently
      """
      decompositions, _ = get_shorter_decompositions(np.ones(order))
      graph = defaultdict(lambda: list())
      graph_reversed = defaultdict(lambda: list())
      for dec in decompositions:
          parents, weights = get_shorter_decompositions(dec)
          for i in range(len(parents)):
              graph[parents[i]].append((dec, weights[i]))
              graph_reversed[dec].append((parents[i], weights[i]))
  
      topo_order = sort_topologically(graph, decompositions)
  
      final_coefs = defaultdict(lambda: 0)
      for node in topo_order:
          final_coefs[node] += initial_coefficient(node)
          for p, w in graph_reversed[node]:
              final_coefs[p] -= w * final_coefs[node]
      powers_and_coefs_list = []
      # for dec, c in final_coefs.iteritems():
      for dec, c in final_coefs.items():
          in_pows, out_pows = np.unique(dec, return_counts=True)
          powers_and_coefs_list.append((in_pows, out_pows, c))
  
      return powers_and_coefs_list
  
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 4 for calling a global function with example usage: powers_and_coefs(order) and returns: powers_and_coefs_list