code: def reverse_lookup_from_nested_dict(values_dict):
      
      reverse_lookup = defaultdict(list)
      for column_key, column_dict in values_dict.items():
          for row_key, value in column_dict.items():
              entry = (column_key, value)
              reverse_lookup[row_key].append(entry)
      return reverse_lookup
docs: Create reverse-lookup dictionary mapping each row key to a list of triplets:
      [(column key, value), ...]
  
      Parameters
      ----------
      nested_values_dict : dict
          column_key -> row_key -> value
  
      weights_dict : dict
          column_key -> row_key -> sample weight
  
      Returns dictionary mapping row_key -> [(column key, value)]