code: def _test_data_quality_monitor_created_by_attach(
      sagemaker_session, model_monitor_cls, describe_job_definition
  ):
      # mock
      sagemaker_session.describe_monitoring_schedule = MagicMock(
          return_value={
              "MonitoringScheduleArn": SCHEDULE_ARN,
              "MonitoringScheduleName": SCHEDULE_NAME,
              "MonitoringScheduleConfig": {
                  "MonitoringJobDefinitionName": JOB_DEFINITION_NAME,
                  "MonitoringType": model_monitor_cls.monitoring_type(),
              },
          }
      )
      sagemaker_session.list_tags = MagicMock(return_value=TAGS)
      describe_job_definition.return_value = {
          "RoleArn": ROLE,
          "JobResources": JOB_RESOURCES,
          "{}JobOutputConfig".format(
              model_monitor_cls.monitoring_type()
          ): {
              "KmsKeyId": OUTPUT_KMS_KEY,
          },
          "NetworkConfig": NETWORK_CONFIG._to_request_dict(),
          "StoppingCondition": STOP_CONDITION,
          "{}AppSpecification".format(
              model_monitor_cls.monitoring_type()
          ): {"Environment": ENVIRONMENT},
      }
  
      # attach
      data_quality_monitor = model_monitor_cls.attach(
          SCHEDULE_NAME, sagemaker_session
      )
  
      # validation
      sagemaker_session.describe_monitoring_schedule.assert_called_once_with(
          monitoring_schedule_name=SCHEDULE_NAME
      )
      sagemaker_session.list_tags.assert_called_once_with(
          resource_arn=SCHEDULE_ARN
      )
      describe_job_definition.assert_called_once_with(
          JobDefinitionName=JOB_DEFINITION_NAME
      )
      assert (
          data_quality_monitor.monitoring_schedule_name == SCHEDULE_NAME
      )
      assert (
          data_quality_monitor.job_definition_name
          == JOB_DEFINITION_NAME
      )
      assert data_quality_monitor.env == ENVIRONMENT
      assert data_quality_monitor.instance_count == INSTANCE_COUNT
      assert data_quality_monitor.instance_type == INSTANCE_TYPE
      assert (
          data_quality_monitor.max_runtime_in_seconds
          == MAX_RUNTIME_IN_SECONDS
      )
      assert data_quality_monitor.output_kms_key == OUTPUT_KMS_KEY
      assert data_quality_monitor.role == ROLE
      assert data_quality_monitor.tags == TAGS
      assert data_quality_monitor.volume_kms_key == VOLUME_KMS_KEY
      assert data_quality_monitor.volume_size_in_gb == VOLUME_SIZE_IN_GB
      assert (
          not data_quality_monitor.network_config.enable_network_isolation
      )
      data_quality_monitor.network_config = (
          NETWORK_CONFIG  # Restore the object for validation
      )
      return data_quality_monitor
  
imports: from __future__ import absolute_import
  import copy
  import time
  from typing import Union
  import sagemaker
  import pytest
  from mock import Mock, patch, MagicMock
  from sagemaker.model_monitor import ModelMonitor, Constraints, CronExpressionGenerator, DefaultModelMonitor, EndpointInput, BatchTransformInput, ModelQualityMonitor, Statistics, MonitoringOutput, DataQualityMonitoringConfig, DataQualityDistributionConstraints
  from sagemaker.model_monitor.monitoring_alert import MonitoringAlertSummary, MonitoringAlertHistorySummary, MonitoringAlertActions, ModelDashboardIndicatorAction
  from sagemaker.network import NetworkConfig
  from sagemaker.model_monitor.dataset_format import MonitoringDatasetFormat, DatasetFormat
  from tests.unit import SAGEMAKER_CONFIG_MONITORING_SCHEDULE
label_desc: Use image node_id 21 for calling a global function with example usage: _test_data_quality_monitor_created_by_attach(sagemaker_session, model_monitor_cls, describe_job_definition) and returns: data_quality_monitor