code: def count_failures(log_file_name, pattern):
      counter = Counter()
      with open(log_file_name) as f:
          for line in f:
              try:
                  line = json.loads(line)
              except Exception:
                  continue
              if (
                  "location" in line
                  and line["when"] == "call"
                  and line["outcome"] == "failed"
              ):
                  line_module_name = line["location"][0].removeprefix(
                      PANDAS_TEST_PREFIX
                  )
                  if fnmatch(line_module_name, pattern):
                      if "longrepr" in line and line["longrepr"]:
                          if isinstance(
                              line["longrepr"], (tuple, list)
                          ):
                              message = line["longrepr"][
                                  2
                              ].splitlines()[0]
                          elif isinstance(line["longrepr"], str):
                              message = line["longrepr"]
                          else:
                              message = line["longrepr"]["reprcrash"][
                                  "message"
                              ].splitlines()[0]
                          counter[message] += 1
      return counter
  
imports: import json
  import sys
  from collections import Counter
  from fnmatch import fnmatch
  from rich.console import Console
  from rich.table import Table
label_desc: Use image node_id 1 for calling a global function with example usage: count_failures(log_file_name, pattern) and returns: counter