code: def get_run_ids(
      dag: DAG,
      run_id: str,
      future: bool,
      past: bool,
      session: SASession = NEW_SESSION,
  ):
      """Return DAG executions' run_ids."""
      last_dagrun = dag.get_last_dagrun(
          include_externally_triggered=True, session=session
      )
      current_dagrun = dag.get_dagrun(run_id=run_id, session=session)
      first_dagrun = session.scalar(
          select(DagRun)
          .filter(DagRun.dag_id == dag.dag_id)
          .order_by(DagRun.execution_date.asc())
          .limit(1)
      )
  
      if last_dagrun is None:
          raise ValueError(f"DagRun for {dag.dag_id} not found")
  
      # determine run_id range of dag runs and tasks to consider
      end_date = (
          last_dagrun.logical_date
          if future
          else current_dagrun.logical_date
      )
      start_date = (
          current_dagrun.logical_date
          if not past
          else first_dagrun.logical_date
      )
      if not dag.timetable.can_be_scheduled:
          # If the DAG never schedules, need to look at existing DagRun if the user wants future or
          # past runs.
          dag_runs = dag.get_dagruns_between(
              start_date=start_date, end_date=end_date, session=session
          )
          run_ids = sorted({d.run_id for d in dag_runs})
      elif not dag.timetable.periodic:
          run_ids = [run_id]
      else:
          dates = [
              info.logical_date
              for info in dag.iter_dagrun_infos_between(
                  start_date, end_date, align=False
              )
          ]
          run_ids = [
              dr.run_id
              for dr in DagRun.find(
                  dag_id=dag.dag_id,
                  execution_date=dates,
                  session=session,
              )
          ]
      return run_ids
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Collection, Iterable, Iterator, NamedTuple
  from sqlalchemy import or_, select
  from sqlalchemy.orm import lazyload
  from airflow.models.dagrun import DagRun
  from airflow.models.taskinstance import TaskInstance
  from airflow.operators.subdag import SubDagOperator
  from airflow.utils import timezone
  from airflow.utils.helpers import exactly_one
  from airflow.utils.session import NEW_SESSION, provide_session
  from airflow.utils.state import DagRunState, State, TaskInstanceState
  from airflow.utils.types import DagRunType
label_desc: Use image node_id 10 for calling a global function with example usage: get_run_ids(dag, run_id, future, past, session) and returns: run_ids