code: def test_pipeline_start_selective_execution(sagemaker_session_mock):
      sagemaker_session_mock.sagemaker_client.start_pipeline_execution.return_value = {
          "PipelineExecutionArn": "my:arn"
      }
      pipeline = Pipeline(
          name="MyPipeline",
          parameters=[],
          steps=[],
          sagemaker_session=sagemaker_session_mock,
      )
  
      # Case 1: Happy path
      selective_execution_config = SelectiveExecutionConfig(
          source_pipeline_execution_arn="foo-arn",
          selected_steps=["step-1", "step-2", "step-3"],
      )
      pipeline.start(
          selective_execution_config=selective_execution_config
      )
      sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with(
          PipelineName="MyPipeline",
          SelectiveExecutionConfig={
              "SelectedSteps": [
                  {"StepName": "step-1"},
                  {"StepName": "step-2"},
                  {"StepName": "step-3"},
              ],
              "SourcePipelineExecutionArn": "foo-arn",
          },
      )
      sagemaker_session_mock.reset_mock()
  
      # Case 2: Start selective execution without SourcePipelineExecutionArn
      # References latest execution by default.
      sagemaker_session_mock.sagemaker_client.list_pipeline_executions.return_value = {
          "PipelineExecutionSummaries": [
              {
                  "PipelineExecutionArn": "my:latest:execution:arn",
                  "PipelineExecutionDisplayName": "Latest",
              }
          ]
      }
      selective_execution_config = SelectiveExecutionConfig(
          selected_steps=["step-1", "step-2", "step-3"]
      )
      pipeline.start(
          selective_execution_config=selective_execution_config
      )
      sagemaker_session_mock.sagemaker_client.list_pipeline_executions.assert_called_with(
          PipelineName="MyPipeline",
          SortBy="CreationTime",
          SortOrder="Descending",
          MaxResults=1,
      )
      sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with(
          PipelineName="MyPipeline",
          SelectiveExecutionConfig={
              "SelectedSteps": [
                  {"StepName": "step-1"},
                  {"StepName": "step-2"},
                  {"StepName": "step-3"},
              ],
              "SourcePipelineExecutionArn": "my:latest:execution:arn",
          },
      )
      sagemaker_session_mock.reset_mock()
  
      # Case 3: Start selective execution without SourcePipelineExecutionArn
      # Opts not to reference latest execution.
      selective_execution_config = SelectiveExecutionConfig(
          selected_steps=["step-1", "step-2", "step-3"],
          reference_latest_execution=False,
      )
      pipeline.start(
          selective_execution_config=selective_execution_config
      )
      sagemaker_session_mock.sagemaker_client.list_pipeline_executions.assert_not_called()
      sagemaker_session_mock.sagemaker_client.start_pipeline_execution.assert_called_with(
          PipelineName="MyPipeline",
          SelectiveExecutionConfig={
              "SelectedSteps": [
                  {"StepName": "step-1"},
                  {"StepName": "step-2"},
                  {"StepName": "step-3"},
              ],
          },
      )
      sagemaker_session_mock.reset_mock()
  
imports: from __future__ import absolute_import
  import copy
  import json
  import pytest
  from mock import Mock, call, patch
  from sagemaker import s3
  from sagemaker.remote_function.job import _JobSettings
  from sagemaker.session_settings import SessionSettings
  from sagemaker.workflow.condition_step import ConditionStep
  from sagemaker.workflow.conditions import ConditionEquals
  from sagemaker.workflow.execution_variables import ExecutionVariables
  from sagemaker.workflow.function_step import DelayedReturn, step
  from sagemaker.workflow.functions import JsonGet, Join
  from sagemaker.workflow.parameters import ParameterString
  from sagemaker.workflow.pipeline import Pipeline, PipelineGraph, _replace_pipeline_name_in_json_get_s3_uri
  from sagemaker.workflow.pipeline_context import _PipelineConfig
  from sagemaker.workflow.pipeline_definition_config import PipelineDefinitionConfig
  from sagemaker.workflow.pipeline_experiment_config import PipelineExperimentConfig, PipelineExperimentConfigProperties
  from sagemaker.workflow.step_collections import StepCollection
  from tests.unit.sagemaker.workflow.helpers import ordered, CustomStep, CustomFunctionStep
  from sagemaker.local.local_session import LocalSession
  from botocore.exceptions import ClientError
  from sagemaker.workflow.selective_execution_config import SelectiveExecutionConfig
label_desc: Use image node_id 17 for calling a global function with example usage: test_pipeline_start_selective_execution(sagemaker_session_mock) without return types