code: def extract_commit_hash(
      resolved_dir: str, regex_commit_hash: t.Pattern[str]
  ) -> str | None:
      """
      Extracts the commit hash from a resolved filename toward a cache file.
      modified from https://github.com/huggingface/transformers/blob/0b7b4429c78de68acaf72224eb6dae43616d820c/src/transformers/utils/hub.py#L219
      """
  
      resolved_dir = str(Path(resolved_dir).as_posix()) + "/"
      search = re.search(r"snapshots/([^/]+)/", resolved_dir)
  
      if search is None:
          return None
  
      commit_hash = search.groups()[0]
      return (
          commit_hash if regex_commit_hash.match(commit_hash) else None
      )
  
file_path: BentoML/src/bentoml/_internal/frameworks/utils/transformers.py
imports: from __future__ import annotations
  import importlib.metadata
  import importlib.util
  import logging
  import re
  import typing
  from contextlib import contextmanager
  from pathlib import Path
  import torch
  import torch.nn
  from packaging import version
label_desc: Use image node_id 4 for calling a global function with example usage: extract_commit_hash(resolved_dir, regex_commit_hash) and returns: unknown, None