code: def create_and_execute_pipeline(
      pipeline: Pipeline,
      pipeline_name,
      region_name,
      role,
      no_of_steps,
      last_step_name,
      execution_parameters,
      step_status,
      step_result_type=None,
      step_result_value=None,
      wait_duration=400,  # seconds
  ):
      response = pipeline.create(role)
  
      create_arn = response["PipelineArn"]
      assert re.match(
          rf"arn:aws:sagemaker:{region_name}:\d{{12}}:pipeline/{pipeline_name}",
          create_arn,
      )
  
      execution = pipeline.start(parameters=execution_parameters)
      response = execution.describe()
      assert response["PipelineArn"] == create_arn
  
      wait_pipeline_execution(
          execution=execution,
          delay=20,
          max_attempts=int(wait_duration / 20),
      )
  
      execution_steps = execution.list_steps()
  
      assert (
          len(execution_steps) == no_of_steps
      ), f"Expected {no_of_steps}, instead found {len(execution_steps)}"
  
      assert last_step_name in execution_steps[0]["StepName"]
      assert execution_steps[0]["StepStatus"] == step_status
      if step_result_type:
          result = execution.result(execution_steps[0]["StepName"])
          assert (
              type(result) == step_result_type
          ), f"Expected {step_result_type}, instead found {type(result)}"
  
      if step_result_value:
          result = execution.result(execution_steps[0]["StepName"])
          assert (
              result == step_result_value
          ), f"Expected {step_result_value}, instead found {result}"
      return execution, execution_steps
  
file_path: sagemaker-python-sdk/tests/integ/sagemaker/workflow/helpers.py
imports: from __future__ import absolute_import
  import re
  from botocore.exceptions import WaiterError
  from sagemaker import Session
  from sagemaker.workflow.pipeline import _PipelineExecution
  from sagemaker.workflow.pipeline import Pipeline
label_desc: Use image node_id 2 for calling a global function with example usage: create_and_execute_pipeline(pipeline, pipeline_name, region_name, role, no_of_steps, last_step_name, execution_parameters, step_status, step_result_type, step_result_value, wait_duration) and returns: execution,  execution_steps