code: def connect_to_instance(instance, keypath, username, http_proxy=None):
      print(f"Connecting to {instance.id}...")
  
      ip_address = instance.public_ip_address
      if http_proxy:
          # paramiko.ProxyCommand does not do string substitution for %h %p,
          # so 'nc --proxy-type http --proxy fwdproxy:8080 %h %p' would not work!
          proxy = paramiko.ProxyCommand(
              f"nc --proxy-type http --proxy {http_proxy} {ip_address} {22}"
          )
          proxy.settimeout(300)
      client = paramiko.SSHClient()
      client.load_system_host_keys()
      client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      retries = 20
      while retries > 0:
          try:
              client.connect(
                  ip_address,
                  username=username,
                  key_filename=keypath,
                  timeout=10,
                  sock=proxy if http_proxy else None,
              )
              print(f"Connected to {instance.id}")
              break
          except Exception as e:
              print(f"Exception: {e} Retrying...")
              retries -= 1
              time.sleep(10)
      return client
  
file_path: CrypTen/scripts/aws_launcher.py
imports: import concurrent.futures
  import configparser
  import os
  import sys
  import time
  import uuid
  import warnings
  from argparse import ArgumentParser, REMAINDER
  from pathlib import Path
  import boto3
  import paramiko
label_desc: Use image node_id 2 for calling a global function with example usage: connect_to_instance(instance, keypath, username, http_proxy) and returns: client