code: def _wait_for_completion(monitor):
      """Waits for the schedule to have an execution in a terminal status.
  
      Args:
          monitor (sagemaker.model_monitor.ModelMonitor): The monitor to watch.
  
      """
      for _ in retries(
          max_retry_count=200,
          exception_message_prefix="Waiting for the latest execution to be in a terminal status.",
          seconds_to_sleep=60,
      ):
          schedule_desc = monitor.describe_schedule()
          execution_summary = schedule_desc.get(
              "LastMonitoringExecutionSummary"
          )
          last_execution_status = None
  
          # Once there is an execution, get its status
          if execution_summary is not None:
              last_execution_status = execution_summary[
                  "MonitoringExecutionStatus"
              ]
              # Stop the schedule as soon as it's kicked off the execution that we need from it.
              if schedule_desc["MonitoringScheduleStatus"] not in [
                  "Pending",
                  "Stopped",
              ]:
                  monitor.stop_monitoring_schedule()
          # End this loop once the execution has reached a terminal state.
          if last_execution_status in [
              "Completed",
              "CompletedWithViolations",
              "Failed",
              "Stopped",
          ]:
              break
  
imports: from __future__ import print_function, absolute_import
  import tempfile
  from datetime import datetime, timedelta
  import json
  import os
  import numpy
  import pytest
  import pandas
  import tests.integ
  import tests.integ.timeout
  from sagemaker import image_uris, utils
  from sagemaker.model_monitor import CronExpressionGenerator, DataCaptureConfig, EndpointInput, ModelQualityMonitor, DatasetFormat
  from sagemaker.s3 import S3Uploader
  from sagemaker.utils import unique_name_from_base
  from sagemaker.model import Model
  from tests.integ import DATA_DIR
  from tests.integ.retry import retries
label_desc: Use image node_id 16 for calling a global function with example usage: _wait_for_completion(monitor) without return types