code: def _hash_file_or_dir(path: str, md5: Hash) -> Hash:
      """Updates the inputted Hash with the contents of the current path.
  
      Args:
          path: path of file or directory
      Returns:
          str: The MD5 hash of the file or directory
      """
      if isinstance(path, str) and path.lower().startswith("file://"):
          path = unquote(urlparse(path).path)
      md5.update(path.encode())
      if Path(path).is_dir():
          md5 = _hash_dir(path, md5)
      elif Path(path).is_file():
          md5 = _hash_file(path, md5)
      return md5
  
imports: from __future__ import absolute_import
  import inspect
  import logging
  from functools import wraps
  from pathlib import Path
  from typing import List, Sequence, Union, Set, TYPE_CHECKING, Optional
  import hashlib
  from urllib.parse import unquote, urlparse
  from contextlib import contextmanager
  from _hashlib import HASH
  from sagemaker.utils import base_from_name
  from sagemaker.workflow.parameters import Parameter
  from sagemaker.workflow.pipeline_context import _StepArguments, _PipelineConfig
  from sagemaker.workflow.entities import Entity, RequestType
  from sagemaker.workflow.pipeline_definition_config import PipelineDefinitionConfig
label_desc: Use image node_id 12 for calling a global function with example usage: _hash_file_or_dir(path, md5) and returns: md5