code: def get_dimension_permutations(entities, dimensions):
      
      new_dimensions = defaultdict(int)
      for item in dimensions:
          new = entities[item['base']].dimensions
          if new:
              for new_item in new:
                  new_dimensions[new_item['base']] += new_item['power'] * \
                                                   item['power']
          else:
              new_dimensions[item['base']] += item['power']
  
      final = [[{'base': i[0], 'power': i[1]} for i in new_dimensions.items()]]
      final.append(dimensions)
      final = [sorted(i, key=lambda x: x['base']) for i in final]
  
      candidates = []
      for item in final:
          if item not in candidates:
              candidates.append(item)
  
      return candidates
docs: Get all possible dimensional definitions for an entity.