code: def timeout_and_delete_endpoint_by_name(
      endpoint_name,
      sagemaker_session,
      seconds=0,
      minutes=45,
      hours=0,
      sleep_between_cleanup_attempts=10,
      exponential_sleep=False,
  ):
      limit = seconds + 60 * minutes + 3600 * hours
  
      with stopit.ThreadingTimeout(limit, swallow_exc=False) as t:
          no_errors = False
          try:
              yield [t]
              no_errors = True
          finally:
              attempts = 3
  
              while attempts > 0:
                  attempts -= 1
                  try:
                      _delete_schedules_associated_with_endpoint(
                          sagemaker_session=sagemaker_session,
                          endpoint_name=endpoint_name,
                      )
                      sagemaker_session.delete_endpoint(endpoint_name)
                      logger.info("deleted endpoint %s", endpoint_name)
  
                      _show_logs(
                          endpoint_name, "Endpoints", sagemaker_session
                      )
                      if no_errors:
                          _cleanup_logs(
                              endpoint_name,
                              "Endpoints",
                              sagemaker_session,
                          )
                      break
                  except ClientError as ce:
                      if (
                          ce.response["Error"]["Code"]
                          == "ValidationException"
                      ):
                          # avoids the inner exception to be overwritten
                          pass
                  # trying to delete the resource again in 10 seconds
                  if exponential_sleep:
                      _sleep_between_cleanup_attempts = (
                          sleep_between_cleanup_attempts
                          * (3 - attempts)
                      )
                  else:
                      _sleep_between_cleanup_attempts = (
                          sleep_between_cleanup_attempts
                      )
                  sleep(_sleep_between_cleanup_attempts)
  
file_path: sagemaker-python-sdk/tests/integ/timeout.py
imports: from __future__ import absolute_import
  from contextlib import contextmanager
  import logging
  from time import sleep
  from awslogs.core import AWSLogs
  from botocore.exceptions import ClientError
  import stopit
  from sagemaker import Predictor
  from tests.integ.retry import retries
label_desc: Use image node_id 2 for calling a global function with example usage: timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session, seconds, minutes, hours, sleep_between_cleanup_attempts, exponential_sleep) without return types