code: def download_from_s3(
      s3_url: str,
      cache_dir: str = None,
      access_key: str = None,
      secret_access_key: str = None,
      region_name: str = None,
  ):
      """
      Download a "folder" from s3 to local. Skip already existing files. Useful for downloading all files of one model
      The default and recommended authentication follows boto3's trajectory of checking for ENV variables,
      .aws/credentials etc. (see https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html).
      However, there's also the option to pass `access_key`, `secret_access_key` and `region_name` directly
      as this is needed in some enterprise enviroments with local s3 deployments.
  
      :param s3_url: Url of the "folder" in s3 (e.g. s3://mybucket/my_modelname)
      :param cache_dir: Optional local directory where the files shall be stored.
                        If not supplied, we'll use a subfolder in torch's cache dir (~/.cache/torch/farm)
      :param access_key: Optional S3 Access Key
      :param secret_access_key: Optional S3 Secret Access Key
      :param region_name: Optional Region Name
      :return: local path of the folder
      """
  
      if cache_dir is None:
          cache_dir = FARM_CACHE
  
      logger.info(f"Downloading from {s3_url} to {cache_dir}")
  
      if access_key or secret_access_key:
          assert (
              secret_access_key and access_key
          ), "You only supplied one of secret_access_key and access_key. We need both."
  
          session = boto3.Session(
              aws_access_key_id=access_key,
              aws_secret_access_key=secret_access_key,
              region_name=region_name,
          )
          s3_resource = session.resource("s3")
      else:
          s3_resource = boto3.resource("s3")
  
      bucket_name, s3_path = split_s3_path(s3_url)
      bucket = s3_resource.Bucket(bucket_name)
      objects = bucket.objects.filter(Prefix=s3_path)
      if not objects:
          raise ValueError("Could not find s3_url: {s3_url}")
  
      for obj in objects:
          path, filename = os.path.split(obj.key)
          path = os.path.join(cache_dir, path)
          # Create local folder
          if not os.path.exists(path):
              os.makedirs(path)
          # Download file if not present locally
          if filename:
              filepath = os.path.join(path, filename)
              if os.path.exists(filepath):
                  logger.info(f"Skipping {obj.key} (exists locally)")
              else:
                  logger.info(
                      f"Downloading {obj.key} to {filepath} (size: {obj.size/1000000} MB)"
                  )
                  bucket.download_file(obj.key, filepath)
      return path
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import json
  import logging
  import os
  import tempfile
  import tarfile
  import zipfile
  from functools import wraps
  from hashlib import sha256
  from io import open
  from pathlib import Path
  import boto3
  import numpy
  import requests
  from botocore.exceptions import ClientError
  from dotmap import DotMap
  from tqdm import tqdm
  from transformers.file_utils import cached_path
label_desc: Use image node_id 3 for calling a global function with example usage: download_from_s3(s3_url, cache_dir, access_key, secret_access_key, region_name) and returns: path