code: def static_endpoint_context(
      sagemaker_session, static_pipeline_execution_arn
  ):
      endpoint_arn = get_endpoint_arn_from_static_pipeline(
          sagemaker_session
      )
      logging.info(
          f"Using endpoint {endpoint_arn} from static pipeline"
      )
  
      # if the endpoint doesn't exist deploy it
      if endpoint_arn is None:
          _deploy_static_endpoint(
              execution_arn=static_pipeline_execution_arn,
              sagemaker_session=sagemaker_session,
          )
          endpoint_arn = get_endpoint_arn_from_static_pipeline(
              sagemaker_session
          )
  
      contexts = sagemaker_session.sagemaker_client.list_contexts(
          SourceUri=endpoint_arn
      )["ContextSummaries"]
  
      logging.info(
          f"Found {len(contexts)} contexts associated with {endpoint_arn}"
      )
      for ctx in contexts:
          logging.info(f'Found context "{ctx["ContextArn"]}"')
  
      if len(contexts) == 0:
          raise (
              Exception(
                  f"Got an unexpected number of Contexts for \
                  endpoint {STATIC_ENDPOINT_NAME} from pipeline \
                  execution {static_pipeline_execution_arn}. \
                  Expected 1 but got {len(contexts)}"
              )
          )
  
      endpoint_context = contexts[0]
      context_arn = endpoint_context["ContextArn"]
      logging.info(
          f"Using context {context_arn} for static endpoint context"
      )
      yield context.EndpointContext.load(
          endpoint_context["ContextName"],
          sagemaker_session=sagemaker_session,
      )
  
imports: from __future__ import absolute_import
  import time
  import boto3
  import pytest
  import logging
  import uuid
  import json
  from sagemaker.lineage import action, context, association, artifact
  from sagemaker.model import ModelPackage
  from sagemaker.utils import retry_with_backoff
  from tests.integ.sagemaker.workflow.test_workflow import test_end_to_end_pipeline_successful_execution
  from sagemaker.workflow.pipeline import _PipelineExecution
  from sagemaker.session import get_execution_role
  from smexperiments import trial_component, trial, experiment
  from random import randint
  from botocore.exceptions import ClientError
  from sagemaker.lineage.query import LineageQuery, LineageFilter, LineageSourceEnum, LineageEntityEnum, LineageQueryDirectionEnum
  from sagemaker.lineage.lineage_trial_component import LineageTrialComponent
  from tests.integ.sagemaker.lineage.helpers import name, names
label_desc: Use image node_id 33 for calling a global function with example usage: static_endpoint_context(sagemaker_session, static_pipeline_execution_arn) without return types