code: def test_model_details_autodiscovery(session):
      session.sagemaker_client.describe_model.side_effect = [
          DESCRIBE_MODEL_EXAMPLE,
          DESCRIBE_MODEL_EXAMPLE,
          MISSING_MODEL_CLIENT_ERROR,
      ]
  
      session.sagemaker_client.search.side_effect = [
          SEARCH_MODEL_CARD_WITH_MODEL_ID_EMPTY_EXAMPLE,
          SEARCH_MODEL_CARD_WITH_MODEL_ID_EXAMPLE,
      ]
  
      model = ModelOverview.from_model_name(
          MODEL_NAME, sagemaker_session=session
      )
      assert model.model_name == MODEL_NAME
      assert model.model_id == MODEL_ID
      assert model.inference_environment.container_image == [
          MODEL_IMAGE
      ]
      assert model.model_artifact == [MODEL_ARTIFACT[0]]
  
      with pytest.raises(
          ValueError,
          match=re.escape(
              f"The model has been associated with {[MODEL_CARD_NAME]} model cards."
          ),
      ):
          ModelOverview.from_model_name(
              MODEL_NAME, sagemaker_session=session
          )
  
      with pytest.raises(
          ValueError,
          match=re.escape(
              f"Model details for model {MODEL_NAME} could not be found. Make sure the model name is valid."  # noqa E501  # pylint: disable=c0301
          ),
      ):
          ModelOverview.from_model_name(
              MODEL_NAME, sagemaker_session=session
          )
  
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 28 for calling a global function with example usage: test_model_details_autodiscovery(session) without return types