code: def transpose_nested_dictionary(nested_dict):
      """
      Given a nested dictionary from k1 -> k2 > value
      transpose its outer and inner keys so it maps
      k2 -> k1 -> value.
      """
      result = defaultdict(dict)
      for k1, d in nested_dict.items():
          for k2, v in d.items():
              result[k2][k1] = v
      return result
  
imports: from collections import defaultdict
  import numpy
  from scipy.sparse import dok_matrix
label_desc: Use image node_id 17 for calling a global function with example usage: transpose_nested_dictionary(nested_dict) and returns: result