code: def test_create_model_card_with_model_package(
      session, model_package_example, training_details_example, caplog
  ):
      session.sagemaker_client.create_model_card = Mock(
          return_value=CREATE_MODEL_CARD_RETURN_EXAMPLE
      )
      session.sagemaker_client.describe_model_card = Mock(
          return_value=MODEL_CARD_WITH_MODEL_PACKAGE_MOCK_RESPONSE
      )
  
      session.sagemaker_client.search.side_effect = [
          SEARCH_TRAINING_JOB_EXAMPLE,
          SEARCH_LATEST_MODEL_CARD_WITH_EMPTY_RESULT_EXAMPLE,
          SEARCH_LATEST_MODEL_CARD_WITH_EMPTY_RESULT_EXAMPLE,
      ]
  
      card = ModelCard(
          name=MODEL_CARD_NAME,
          status=MODEL_CARD_STATUS,
          model_package_details=model_package_example,
          sagemaker_session=session,
      )
  
      card.create()
  
      assert card.arn == MODEL_CARD_ARN
      assert card.status == MODEL_CARD_STATUS
      assert (
          card.model_package_details.model_package_arn
          == MODEL_PACKAGE_ARN
      )
      assert (
          card.model_package_details.model_approval_status
          == MODEL_APPROVAL_STATUS
      )
      assert (
          card.model_package_details.created_by.user_profile_name
          == USER_PROFILE_NAME
      )
  
      # testing with existing training details
      with caplog.at_level(logging.INFO):
          ModelCard(
              name=MODEL_CARD_NAME,
              status=MODEL_CARD_STATUS,
              training_details=training_details_example,
              model_package_details=model_package_example,
              sagemaker_session=session,
          )
          assert (
              "Skipping training details auto discovery. "
              "Training details already exists for this model card."
          ) in caplog.text
  
imports: from __future__ import absolute_import
  import io
  import os
  import json
  import datetime
  import re
  import logging
  import pytest
  from mock import patch, Mock
  from botocore.exceptions import ClientError
  import botocore.response
  from sagemaker.model_card import schema_constraints
  from sagemaker.model_card import Environment, ModelOverview, IntendedUses, BusinessDetails, ObjectiveFunction, TrainingMetric, HyperParameter, Metric, TrainingDetails, MetricGroup, EvaluationJob, AdditionalInformation, ModelCard, Function, TrainingJobDetails, ModelPackage
  from sagemaker.model_card.model_card import ModelCardExportJob, ModelPackageCreator, SourceAlgorithm, Container, InferenceSpecification
  from sagemaker.model_card.helpers import _MaxSizeArray, _IsList, _OneOf, _IsModelCardObject, _JSONEncoder, _hash_content_str, _DefaultToRequestDict, _SkipEncodingDecoding
  from sagemaker.model_card.evaluation_metric_parsers import EvaluationMetricTypeEnum, EVALUATION_METRIC_PARSERS
label_desc: Use image node_id 9 for calling a global function with example usage: test_create_model_card_with_model_package(session, model_package_example, training_details_example, caplog) without return types