code: def _hash_dir(directory: Union[str, Path], md5: Hash) -> Hash:
      """Updates the inputted Hash with the contents of the current path.
  
      Args:
          directory: path of the directory
      Returns:
          str: The MD5 hash of the directory
      """
      if not Path(directory).is_dir():
          raise ValueError(str(directory) + " is not a valid directory")
      for path in sorted(Path(directory).iterdir()):
          md5.update(path.name.encode())
          if path.is_file():
              md5 = _hash_file(path, md5)
          elif path.is_dir():
              md5 = _hash_dir(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 13 for calling a global function with example usage: _hash_dir(directory, md5) and returns: md5