code: def load_stage_component(cpn, stage: "Stage"):
      if not stage.is_default:
          for stage_component in cpn.stage_components:
              if stage_component.name == stage.name:
                  cpn = stage_component
                  break
          else:
              supported_stage_names = [
                  stage_component.name
                  for stage_component in cpn.stage_components
              ]
              raise ValueError(
                  f"stage `{stage.name}` not supported for component `{cpn.name}`, use one listed in: {supported_stage_names}"
              )
      return cpn
  
imports: import logging
  import typing
  from typing import Optional
label_desc: Use image node_id 2 for calling a global function with example usage: load_stage_component(cpn, stage) and returns: cpn