code: def summarize_result(exposure_summary):
      
      summarization_dicts = {}
      summarizer_flags = {}
  
      # for summarizer_field in summarizer_fields:
      for key, summary_rule in list(summary_rules.items()):
          input_field = summary_rule['input_field']
          if exposure_summary.fields().lookupField(
                  input_field['field_name']) == -1:
              summarizer_flags[key] = False
          else:
              summarizer_flags[key] = True
              summarization_dicts[key] = {}
  
      for feature in exposure_summary.getFeatures():
          exposure_class_name = feature[exposure_class_field['field_name']]
          # for summarizer_field in summarizer_fields:
          for key, summary_rule in list(summary_rules.items()):
              input_field = summary_rule['input_field']
              case_field = summary_rule['case_field']
              case_value = feature[case_field['field_name']]
  
              flag = summarizer_flags[key]
              if not flag:
                  continue
              if case_value in summary_rule['case_values']:
                  if exposure_class_name not in summarization_dicts[key]:
                      summarization_dicts[key][exposure_class_name] = 0
                  value = feature[input_field['field_name']]
                  if isinstance(value, Number):
                      summarization_dicts[key][exposure_class_name] += value
  
      return summarization_dicts
docs: Extract result based on summarizer field value and sum by exposure type.
  
      :param exposure_summary: The layer impact layer.
      :type exposure_summary: QgsVectorLayer
  
      :return: Dictionary of attributes per exposure per summarizer field.
      :rtype: dict
  
      .. versionadded:: 4.2