code: def get_remote_files_with_prefix_to_local(
      remote_path_prefix: str,
      local_dir: str,
      over_write: Optional[bool] = False,
  ) -> Union[str, int]:
      prefix = os.path.basename(remote_path_prefix)
      if remote_path_prefix.startswith(
          "hdfs"
      ):  # hdfs://url:port/file_path
          return file_utils.get_remote_files_with_prefix_to_local(
              remote_path_prefix=remote_path_prefix,
              local_dir=local_dir,
              over_write=over_write,
          )
      elif remote_path_prefix.startswith("s3"):  # s3://bucket/file_path
          access_key_id = os.environ["AWS_ACCESS_KEY_ID"]
          secret_access_key = os.environ["AWS_SECRET_ACCESS_KEY"]
          import boto3
  
          s3_client = boto3.Session(
              aws_access_key_id=access_key_id,
              aws_secret_access_key=secret_access_key,
          ).client("s3")
          path_parts = remote_path_prefix.split("://")[1].split("/")
          bucket = path_parts.pop(0)
          prefix = "/".join(path_parts)
          try:
              response = s3_client.list_objects_v2(
                  Bucket=bucket, Prefix=prefix
              )
              keys = [item["Key"] for item in response["Contents"]]
              [
                  s3_client.download_file(
                      bucket,
                      key,
                      os.path.join(local_dir, os.path.basename(keys)),
                  )  # type: ignore
                  for key in keys
              ]
          except Exception as e:
              invalidOperationError(False, str(e), cause=e)
      return os.path.join(local_dir, prefix)
  
imports: import os
  import subprocess
  import logging
  import shutil
  import functools
  import glob
  from distutils.dir_util import copy_tree
  from bigdl.dllib.utils.log4Error import invalidOperationError
  from bigdl.dllib.utils import file_utils
  from typing import TYPE_CHECKING, List, Callable, Union, Optional
label_desc: Use image node_id 16 for calling a global function with example usage: get_remote_files_with_prefix_to_local(remote_path_prefix, local_dir, over_write) and returns: os, file_utils