code: def filter_metrics(
      metrics,
      ignore_stat_endswith: list[str],
      show_stats: list[str] | None = None,
  ):
      """
      Filter metrics by excluding based on suffix and/or including when matching a pattern
      """
      metrics = [
          m
          for m in metrics
          if not any(m.endswith(s) for s in ignore_stat_endswith)
      ]
      if show_stats is not None:
          metrics = [
              m
              for m in metrics
              if any(
                  fnmatch.fnmatch(m, pattern) for pattern in show_stats
              )
          ]
      return metrics
  
file_path: popmon/popmon/utils.py
imports: from __future__ import annotations
  import fnmatch
  from textwrap import shorten
  from typing import Callable
  import pandas
  from joblib import Parallel, delayed
label_desc: Use image node_id 2 for calling a global function with example usage: filter_metrics(metrics, ignore_stat_endswith, show_stats) and returns: metrics