code: def dag_list_dag_runs(
      args, dag: DAG | None = None, session: Session = NEW_SESSION
  ) -> None:
      """List dag runs for a given DAG."""
      if dag:
          args.dag_id = dag.dag_id
      else:
          dag = DagModel.get_dagmodel(args.dag_id, session=session)
  
          if not dag:
              raise SystemExit(
                  f"DAG: {args.dag_id} does not exist in 'dag' table"
              )
  
      state = args.state.lower() if args.state else None
      dag_runs = DagRun.find(
          dag_id=args.dag_id,
          state=state,
          no_backfills=args.no_backfill,
          execution_start_date=args.start_date,
          execution_end_date=args.end_date,
          session=session,
      )
  
      dag_runs.sort(key=lambda x: x.execution_date, reverse=True)
      AirflowConsole().print_as(
          data=dag_runs,
          output=args.output,
          mapper=lambda dr: {
              "dag_id": dr.dag_id,
              "run_id": dr.run_id,
              "state": dr.state,
              "execution_date": dr.execution_date.isoformat(),
              "start_date": dr.start_date.isoformat()
              if dr.start_date
              else "",
              "end_date": dr.end_date.isoformat()
              if dr.end_date
              else "",
          },
      )
  
imports: from __future__ import annotations
  import ast
  import errno
  import json
  import logging
  import operator
  import signal
  import subprocess
  import sys
  import warnings
  from typing import TYPE_CHECKING
  from sqlalchemy import delete, select
  from airflow import settings
  from airflow.api.client import get_current_api_client
  from airflow.api_connexion.schemas.dag_schema import dag_schema
  from airflow.cli.simple_table import AirflowConsole
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, RemovedInAirflow3Warning
  from airflow.jobs.job import Job
  from airflow.models import DagBag, DagModel, DagRun, TaskInstance
  from airflow.models.dag import DAG
  from airflow.models.serialized_dag import SerializedDagModel
  from airflow.utils import cli, timezone
  from airflow.utils.cli import get_dag, get_dags, process_subdir, sigint_handler, suppress_logs_and_warning
  from airflow.utils.dot_renderer import render_dag, render_dag_dependencies
  from airflow.utils.providers_configuration_loader import providers_configuration_loaded
  from airflow.utils.session import NEW_SESSION, create_session, provide_session
  from airflow.utils.state import DagRunState
label_desc: Use image node_id 20 for calling a global function with example usage: dag_list_dag_runs(args, dag, session) without return types