code: def test_add_inference_specification(sagemaker_session):
      model_package = ModelPackage(
          role="role",
          model_package_arn=MODEL_PACKAGE_VERSIONED_ARN,
          sagemaker_session=sagemaker_session,
      )
  
      image_uris = ["image_uri"]
  
      containers = [{"Image": "image_uri"}]
  
      try:
          model_package.add_inference_specification(
              image_uris=image_uris,
              name="Inference",
              containers=containers,
          )
      except ValueError as ve:
          assert "Cannot have both containers and image_uris." in str(
              ve
          )
  
      try:
          model_package.add_inference_specification(name="Inference")
      except ValueError as ve:
          assert (
              "Should have either containers or image_uris for inference."
              in str(ve)
          )
  
      model_package.add_inference_specification(
          image_uris=image_uris, name="Inference"
      )
  
      sagemaker_session.sagemaker_client.update_model_package.assert_called_with(
          ModelPackageArn=MODEL_PACKAGE_VERSIONED_ARN,
          AdditionalInferenceSpecificationsToAdd=[
              {
                  "Containers": [{"Image": "image_uri"}],
                  "Name": "Inference",
              }
          ],
      )
  
imports: from __future__ import absolute_import
  import copy
  import pytest
  from mock import Mock, patch
  import sagemaker
  from sagemaker.model import ModelPackage
  from sagemaker.model_card.schema_constraints import ModelApprovalStatusEnum
label_desc: Use image node_id 16 for calling a global function with example usage: test_add_inference_specification(sagemaker_session) without return types