code: def _write_summary_file(
      result_json_paths: List[str],
      output_file: IO[str],
      ablation: int = 0,
  ):
      """
      Summarize individual result JSON files.
  
      Take a list of paths to individual result json files and return a single
      file that summarizes all of them.
  
      Parameters
      ----------
      result_json_paths : List[str]
          A list of paths to the individual result JSON files.
      output_file : IO[str]
          The file buffer to write to.
      ablation : int, default=0
          The number of features to remove when doing ablation experiment.
      """
      learner_result_dicts = []
      # Map from feature set names to all features in them
      all_features = defaultdict(set)
      logger = get_skll_logger("experiment")
      yaml = YAML(typ="safe", pure=True)
  
      for json_path_str in result_json_paths:
          json_path = Path(json_path_str)
          if not json_path.exists():
              logger.error(
                  f"JSON results file {json_path} not found. Skipping "
                  "summary creation. You can manually create the "
                  "summary file after the fact by using the "
                  "summarize_results script."
              )
              return
          else:
              with open(json_path) as json_file:
                  obj = json.load(json_file)
                  featureset_name = obj[0]["featureset_name"]
                  if ablation != 0 and "_minus_" in featureset_name:
                      parent_set = featureset_name.split("_minus_", 1)[
                          0
                      ]
                      all_features[parent_set].update(
                          yaml.load(obj[0]["featureset"])
                      )
                  learner_result_dicts.extend(obj)
  
      # Build and write header
      unique_columns = set(learner_result_dicts[0].keys()) - {
          "result_table",
          "descriptive",
      }
      if ablation != 0:
          unique_columns.add("ablated_features")
      header = sorted(unique_columns)
      writer = csv.DictWriter(
          output_file,
          header,
          extrasaction="ignore",
          dialect=csv.excel_tab,
      )
      writer.writeheader()
  
      # Build "ablated_features" list and fix some backward compatible things
      for lrd in learner_result_dicts:
          featureset_name = lrd["featureset_name"]
          if ablation != 0:
              parent_set = featureset_name.split("_minus_", 1)[0]
              ablated_features = all_features[parent_set].difference(
                  yaml.load(lrd["featureset"])
              )
              lrd["ablated_features"] = ""
              if ablated_features:
                  lrd["ablated_features"] = json.dumps(
                      sorted(ablated_features)
                  )
  
          # write out the new learner dict with the readable fields
          writer.writerow(lrd)
  
      output_file.flush()
  
imports: from __future__ import annotations
  import csv
  import json
  import math
  import sys
  from collections import defaultdict
  from pathlib import Path
  from typing import IO, Any, Dict, List, Tuple
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pandas
  import seaborn
  from ruamel.yaml import YAML
  from skll.types import FoldMapping, PathOrStr
  from skll.utils.logging import get_skll_logger
label_desc: Use image node_id 8 for calling a global function with example usage: _write_summary_file(result_json_paths, output_file, ablation) without return types