code: def reduce_by_error(logs, error_filter=None):
      """count each error"""
  
      counter = Counter()
      counter.update([x[1] for x in logs])
      counts = counter.most_common()
      r = {}
      for error, count in counts:
          if error_filter is None or error not in error_filter:
              r[error] = {
                  "count": count,
                  "failed_tests": [
                      (x[2], x[0]) for x in logs if x[1] == error
                  ],
              }
  
      r = dict(
          sorted(
              r.items(), key=lambda item: item[1]["count"], reverse=True
          )
      )
      return r
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/utils/get_ci_error_statistics.py
imports: import argparse
  import json
  import math
  import os
  import subprocess
  import time
  import zipfile
  from collections import Counter
  import requests
label_desc: Use image node_id 6 for calling a global function with example usage: reduce_by_error(logs, error_filter) and returns: r