code: def test_training_details_autodiscovery_from_job_name(session):
      session.sagemaker_client.describe_training_job.side_effect = [
          DESCRIBE_TRAINING_JOB_EXAMPLE,
          MISSING_TRAINING_JOB_CLIENT_ERROR,
      ]
  
      training_details = TrainingDetails.from_training_job_name(
          training_job_name=TRAINING_JOB_NAME, sagemaker_session=session
      )
      assert (
          training_details.training_job_details.training_arn
          == TRAINING_JOB_ARN
      )
      assert len(
          training_details.training_job_details.training_metrics
      ) == len(
          SEARCH_TRAINING_JOB_EXAMPLE["Results"][0]["TrainingJob"][
              "FinalMetricDataList"
          ]
      )
      assert len(
          training_details.training_job_details.hyper_parameters
      ) == len(
          SEARCH_TRAINING_JOB_EXAMPLE["Results"][0]["TrainingJob"][
              "HyperParameters"
          ]
      )
      assert (
          training_details.training_job_details.training_environment.container_image
          == [TRAINING_IMAGE]
      )
  
      with pytest.raises(
          ValueError,
          match=re.escape(
              (
                  "Training job details could not be found. "
                  "Make sure the training job name is valid."
              )
          ),
      ):
          TrainingDetails.from_training_job_name(
              training_job_name=TRAINING_JOB_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 34 for calling a global function with example usage: test_training_details_autodiscovery_from_job_name(session) without return types