code: def retry_with_instance_list(instance_list):
      """Decorator for running an Integ test with an instance_list and
      break on first success
  
      Args:
          instance_list (list): List of Compute instances for integ test.
      Usage:
          @retry_with_instance_list(instance_list=["ml.g3.2", "ml.g2"])
          def sample_function():
              print("xxxx....")
      """
  
      def decorator(func):
          @wraps(func)
          def wrapper(*args, **kwargs):
              if not (
                  instance_list and isinstance(instance_list, list)
              ):
                  error_string = f"Parameter instance_list = {instance_list} \
                  is expected to be a non-empty list of instance types."
                  raise Exception(error_string)
              for i_type in instance_list:
                  logging.info(
                      f"Using the instance type: {i_type} for {func.__name__}"
                  )
                  try:
                      kwargs.update({"instance_type": i_type})
                      func(*args, **kwargs)
                  except CapacityError as e:
                      if i_type != instance_list[-1]:
                          logging.warning(
                              "Failure using instance type: {}. {}".format(
                                  i_type, str(e)
                              )
                          )
                          continue
                      else:
                          raise
                  break
  
          return wrapper
  
      return decorator
  
file_path: sagemaker-python-sdk/tests/integ/utils.py
imports: from __future__ import absolute_import
  import logging
  import shutil
  from functools import wraps
  from botocore.exceptions import ClientError
  from tests.conftest import NO_P3_REGIONS, NO_M4_REGIONS
  from sagemaker.exceptions import CapacityError
  from sagemaker.session import Session
label_desc: Use image node_id 3 for calling a global function with example usage: retry_with_instance_list(instance_list) and returns: decorator, wrapper