code: def render_dag(
      dag: DAG, tis: list[TaskInstance] | None = None
  ) -> graphviz.Digraph:
      """
      Render the DAG object to the DOT object.
  
      If an task instance list is passed, the nodes will be painted according to task statuses.
  
      :param dag: DAG that will be rendered.
      :param tis: List of task instances
      :return: Graphviz object
      """
      if not graphviz:
          raise AirflowException(
              "Could not import graphviz. Install the graphviz python package to fix this error."
          )
      dot = graphviz.Digraph(
          dag.dag_id,
          graph_attr={
              "rankdir": dag.orientation if dag.orientation else "LR",
              "labelloc": "t",
              "label": dag.dag_id,
          },
      )
      states_by_task_id = None
      if tis is not None:
          states_by_task_id = {ti.task_id: ti.state for ti in tis}
  
      _draw_nodes(dag.task_group, dot, states_by_task_id)
  
      for edge in dag_edges(dag):
          # Gets an optional label for the edge; this will be None if none is specified.
          label = dag.get_edge_info(
              edge["source_id"], edge["target_id"]
          ).get("label")
          # Add the edge to the graph with optional label
          # (we can just use the maybe-None label variable directly)
          dot.edge(edge["source_id"], edge["target_id"], label)
  
      return dot
  
file_path: airflow/airflow/utils/dot_renderer.py
imports: from __future__ import annotations
  import warnings
  from typing import TYPE_CHECKING, Any
  from airflow.exceptions import AirflowException
  from airflow.models.baseoperator import BaseOperator
  from airflow.models.mappedoperator import MappedOperator
  from airflow.utils.dag_edges import dag_edges
  from airflow.utils.state import State
  from airflow.utils.task_group import TaskGroup
label_desc: Use image node_id 6 for calling a global function with example usage: render_dag(dag, tis) and returns: dot