code: def assert_s3_file_patterns_exist(
      sagemaker_session, s3_url, file_patterns
  ):
      parsed_url = urlparse(s3_url)
      region = sagemaker_session.boto_region_name
      s3 = boto3.client("s3", region_name=region)
      contents = s3.list_objects_v2(
          Bucket=parsed_url.netloc, Prefix=parsed_url.path.lstrip("/")
      )["Contents"]
      for pattern in file_patterns:
          search_pattern = re.compile(pattern)
          found = [
              x["Key"]
              for x in contents
              if search_pattern.search(x["Key"])
          ]
          if not found:
              raise ValueError(
                  "File {} is not found under {}".format(
                      pattern, s3_url
                  )
              )
  
file_path: sagemaker-python-sdk/tests/integ/s3_utils.py
imports: from __future__ import absolute_import
  import os
  import re
  import tarfile
  import boto3
  from six.moves.urllib.parse import urlparse
label_desc: Use image node_id 2 for calling a global function with example usage: assert_s3_file_patterns_exist(sagemaker_session, s3_url, file_patterns) without return types