class_docstr: TaskReschedule tracks rescheduled task instances.
docstr: Statement for task reschedules for a given the task instance.
  
  :param ti: the task instance to find task reschedules for
  :param descending: If True then records are returned in descending order
  :param try_number: Look for TaskReschedule of the given try_number. Default is None which
      looks for the same try_number of the given task_instance.
  :meta private:
docstr_tok: ["Statement","for","task","reschedules","for","a","given","the","task","instance",".",":","param","ti",":","the","task","instance","to","find","task","reschedules","for",":","param","descending",":","If","True","then","records","are","returned","in","descending","order",":","param","try_number",":","Look","for","TaskReschedule","of","the","given","try_number",".","Default","is","None","which","looks","for","the","same","try_number","of","the","given","task_instance",".",":","meta","private",":"]
code: def stmt_for_task_instance(
      cls,
      ti: TaskInstance | TaskInstancePydantic,
      *,
      try_number: int | None = None,
      descending: bool = False,
  ) -> Select:
      """
      Statement for task reschedules for a given the task instance.
  
      :param ti: the task instance to find task reschedules for
      :param descending: If True then records are returned in descending order
      :param try_number: Look for TaskReschedule of the given try_number. Default is None which
          looks for the same try_number of the given task_instance.
      :meta private:
      """
      if try_number is None:
          try_number = ti.try_number
  
      return (
          select(cls)
          .where(
              cls.dag_id == ti.dag_id,
              cls.task_id == ti.task_id,
              cls.run_id == ti.run_id,
              cls.map_index == ti.map_index,
              cls.try_number == try_number,
          )
          .order_by(desc(cls.id) if descending else asc(cls.id))
      )
  
file_path: airflow/airflow/models/taskreschedule.py
imports: from __future__ import annotations
  import warnings
  from typing import TYPE_CHECKING
  from sqlalchemy import Column, ForeignKeyConstraint, Index, Integer, String, asc, desc, select, text
  from sqlalchemy.ext.associationproxy import association_proxy
  from sqlalchemy.orm import relationship
  from airflow.exceptions import RemovedInAirflow3Warning
  from airflow.models.base import COLLATION_ARGS, ID_LEN, TaskInstanceDependencies
  from airflow.utils.session import NEW_SESSION, provide_session
  from airflow.utils.sqlalchemy import UtcDateTime
label_desc: Use image node_id 2 for calling the TaskReschedule obj's underlying member method code with example usage: obj.stmt_for_task_instance(cls, ti) and returns: select