code: def test_jumpstart_sdk_metric_definitions_instance_type_overrides(
      patched_get_model_specs,
  ):
      patched_get_model_specs.side_effect = get_special_model_spec
  
      model_id = "variant-model"
      region = "us-west-2"
  
      # assert that we can add metric definitions to default
      metrics = metric_definitions.retrieve_default(
          region=region,
          model_id=model_id,
          model_version="*",
          sagemaker_session=mock_session,
          instance_type="ml.p2.48xlarge",
      )
      assert metrics == [
          {
              "Name": "huggingface-textgeyyyuyuyuyneration:train-loss",
              "Regex": "'loss default': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:wtafigo",
              "Regex": "'evasadfasdl_loss': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:eval-loss",
              "Regex": "'eval_loss': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:train-loss",
              "Regex": "'instance family specific': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:noneyourbusiness-loss",
              "Regex": "'loss-noyb': ([0-9]+\\.[0-9]+)",
          },
      ]
  
      # assert that we can override default metric definitions (instance family + instance type
      # specific)
      metrics = metric_definitions.retrieve_default(
          region=region,
          model_id=model_id,
          model_version="*",
          sagemaker_session=mock_session,
          instance_type="ml.p2.12xlarge",
      )
      assert metrics == [
          {
              "Name": "huggingface-textgeyyyuyuyuyneration:train-loss",
              "Regex": "'loss default': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:instance-typemetric-loss",
              "Regex": "'eval_loss': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:eval-loss",
              "Regex": "'eval_loss': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:train-loss",
              "Regex": "'instance type specific': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:noneyourbusiness-loss",
              "Regex": "'loss-noyb instance specific': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeneration:wtafigo",
              "Regex": "'evasadfasdl_loss': ([0-9]+\\.[0-9]+)",
          },
      ]
  
      # assert that we can return default metric definitions for unrecognized instance
      metrics = metric_definitions.retrieve_default(
          region=region,
          model_id=model_id,
          model_version="*",
          sagemaker_session=mock_session,
          instance_type="ml.p9999.48xlarge",
      )
  
      assert metrics == [
          {
              "Name": "huggingface-textgeneration:train-loss",
              "Regex": "'loss default': ([0-9]+\\.[0-9]+)",
          },
          {
              "Name": "huggingface-textgeyyyuyuyuyneration:train-loss",
              "Regex": "'loss default': ([0-9]+\\.[0-9]+)",
          },
      ]
  
file_path: sagemaker-python-sdk/tests/unit/sagemaker/metric_definitions/jumpstart/test_default.py
imports: from __future__ import absolute_import
  from unittest.mock import Mock
  import boto3
  from mock.mock import patch
  import pytest
  from sagemaker import metric_definitions
  from tests.unit.sagemaker.jumpstart.utils import get_spec_from_base_spec, get_special_model_spec
label_desc: Use image node_id 2 for calling a global function with example usage: test_jumpstart_sdk_metric_definitions_instance_type_overrides(patched_get_model_specs) without return types