code: def _delete_schedules_associated_with_endpoint(
      sagemaker_session, endpoint_name
  ):
      """Deletes schedules associated with a given endpoint. Per latest validation, ensures the
      schedule is stopped and no executions are running, before deleting (otherwise latest
      server-side validations will prevent deletes).
  
      Args:
          sagemaker_session (sagemaker.session.Session): A SageMaker Session
              object, used for SageMaker interactions (default: None). If not
              specified, one is created using the default AWS configuration
              chain.
          endpoint_name (str): The name of the endpoint to delete schedules from.
  
      """
      predictor = Predictor(
          endpoint_name=endpoint_name,
          sagemaker_session=sagemaker_session,
      )
      monitors = predictor.list_monitors()
      for monitor in monitors:
          try:
              monitor._wait_for_schedule_changes_to_apply()
              # Stop the schedules to prevent new executions from triggering.
              monitor.stop_monitoring_schedule()
              executions = monitor.list_executions()
              for execution in executions:
                  execution.stop()
              # Wait for all executions to completely stop.
              # Schedules can't be deleted with running executions.
              for execution in executions:
                  for _ in retries(
                      60,
                      "Waiting for executions to stop",
                      seconds_to_sleep=5,
                  ):
                      status = execution.describe()[
                          "ProcessingJobStatus"
                      ]
                      if status == "Stopped":
                          break
              # Delete schedules.
              monitor.delete_monitoring_schedule()
          except Exception as e:
              logger.warning(
                  "Failed to delete monitor %s,\nError: %s",
                  monitor.monitoring_schedule_name,
                  e,
              )
  
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 5 for calling a global function with example usage: _delete_schedules_associated_with_endpoint(sagemaker_session, endpoint_name) without return types