code: def verify_file_dir(
      output_uri: str, expected_uri: str, check_file: bool = False
  ):
      """Verify pipeline output artifact uri by comparing directory structure.
  
      Args:
        output_uri: pipeline output artifact uri.
        expected_uri: recorded pipeline output artifact uri.
        check_file: boolean indicating whether to check file path.
  
      Returns:
        a boolean whether file paths are matching.
      """
      for dir_name, sub_dirs, leaf_files in fileio.walk(expected_uri):
          for sub_dir in sub_dirs:
              new_file_path = os.path.join(
                  dir_name.replace(expected_uri, output_uri, 1), sub_dir
              )
              if not fileio.exists(new_file_path):
                  logging.error("%s doesn't exists.", new_file_path)
                  return False
          if check_file:
              for leaf_file in leaf_files:
                  new_file_path = os.path.join(
                      dir_name.replace(expected_uri, output_uri, 1),
                      leaf_file,
                  )
                  if not fileio.exists(new_file_path):
                      logging.error("%s doesn't exists.", new_file_path)
                      return False
      return True
  
imports: import filecmp
  import os
  from typing import Dict, List, Optional
  from absl import logging
  import tensorflow_model_analysis
  from tfx import types
  from tfx.dsl.io import fileio
  from tfx.experimental.pipeline_testing import pipeline_recorder_utils
  from tfx.orchestration import metadata
  from tfx.types import artifact_utils
  from tfx.utils import io_utils
  from ml_metadata.proto import metadata_store_pb2
  from tensorflow_metadata.proto.v0 import anomalies_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: verify_file_dir(output_uri, expected_uri, check_file) and returns: True, False, False