code: def test_pipeline_session_context_for_model_step(
      pipeline_session_mock,
  ):
      model = Model(
          name="MyModel",
          image_uri="fakeimage",
          model_data=ParameterString(
              name="ModelData", default_value="s3://my-bucket/file"
          ),
          sagemaker_session=pipeline_session_mock,
          entry_point=f"{DATA_DIR}/dummy_script.py",
          source_dir=f"{DATA_DIR}",
          role=_ROLE,
      )
      # CreateModelStep requires runtime repack
      create_step_args = model.create(
          instance_type="c4.4xlarge",
          accelerator_type="ml.eia1.medium",
      )
      # The context should be cleaned up before return
      assert pipeline_session_mock.context is None
      assert create_step_args.create_model_request
      assert not create_step_args.create_model_package_request
      assert len(create_step_args.need_runtime_repack) == 1
  
      # _RegisterModelStep does not require runtime repack
      model.entry_point = None
      model.source_dir = None
      register_step_args = model.register(
          content_types=["text/csv"],
          response_types=["text/csv"],
          inference_instances=["ml.t2.medium", "ml.m5.xlarge"],
          transform_instances=["ml.m5.xlarge"],
          model_package_group_name="MyModelPackageGroup",
          task="IMAGE_CLASSIFICATION",
          sample_payload_url="s3://test-bucket/model",
          framework="TENSORFLOW",
          framework_version="2.9",
          nearest_model_name="resnet50",
          data_input_configuration='{"input_1":[1,224,224,3]}',
      )
      # The context should be cleaned up before return
      assert not pipeline_session_mock.context
      assert not register_step_args.create_model_request
      assert register_step_args.create_model_package_request
      assert len(register_step_args.need_runtime_repack) == 0
  
imports: from __future__ import absolute_import
  import pytest
  from mock import Mock, PropertyMock
  from sagemaker import Model
  from sagemaker.workflow.pipeline_context import PipelineSession
  from sagemaker.workflow import is_pipeline_variable, is_pipeline_parameter_string
  from sagemaker.workflow.parameters import ParameterString, ParameterInteger, ParameterBoolean, ParameterFloat
  from sagemaker.workflow.functions import Join, JsonGet
  from tests.unit.sagemaker.workflow.helpers import CustomStep
  from tests.unit import DATA_DIR, SAGEMAKER_CONFIG_SESSION
label_desc: Use image node_id 5 for calling a global function with example usage: test_pipeline_session_context_for_model_step(pipeline_session_mock) without return types