code: def upload_file(
      client: Any,
      project_arn: str,
      prefix: str,
      filename: str,
      filetype: str,
      mime: str = "application/octet-stream",
  ):
      """
      Upload the app file and XCTest suite to AWS
      """
      r = client.create_upload(
          projectArn=project_arn,
          name=f"{prefix}_{os.path.basename(filename)}",
          type=filetype,
          contentType=mime,
      )
      upload_name = r["upload"]["name"]
      upload_arn = r["upload"]["arn"]
      upload_url = r["upload"]["url"]
  
      with open(filename, "rb") as file_stream:
          print(
              f"Uploading {filename} to Device Farm as {upload_name}..."
          )
          r = requests.put(
              upload_url,
              data=file_stream,
              headers={"content-type": mime},
          )
          if not r.ok:
              raise Exception(f"Couldn't upload {filename}: {r.reason}")
  
      start_time = datetime.datetime.now()
      # Polling AWS till the uploaded file is ready
      while True:
          waiting_time = datetime.datetime.now() - start_time
          if waiting_time > datetime.timedelta(
              seconds=MAX_UPLOAD_WAIT_IN_SECOND
          ):
              raise Exception(
                  f"Uploading {filename} is taking longer than {MAX_UPLOAD_WAIT_IN_SECOND} seconds, terminating..."
              )
  
          r = client.get_upload(arn=upload_arn)
          status = r["upload"].get("status", "")
  
          print(f"{filename} is in state {status} after {waiting_time}")
  
          if status == "FAILED":
              raise Exception(f"Couldn't upload {filename}: {r}")
          if status == "SUCCEEDED":
              break
  
          time.sleep(POLLING_DELAY_IN_SECOND)
  
      return upload_arn
  
file_path: pytorch/ios/TestApp/run_on_aws_devicefarm.py
imports: import datetime
  import os
  import random
  import string
  import sys
  import time
  import warnings
  from typing import Any
  import boto3
  import requests
label_desc: Use image node_id 2 for calling a global function with example usage: upload_file(client, project_arn, prefix, filename, filetype, mime) and returns: upload_arn