class_docstr: CeleryExecutor is recommended for production use of Airflow.
  
  It allows distributing the execution of task instances to multiple worker nodes.
  
  Celery is a simple, flexible and reliable distributed system to process
  vast amounts of messages, while providing operations with the tools
  required to maintain such a system.
class_docstr_tok: ["CeleryExecutor","is","recommended","for","production","use","of","Airflow",".","It","allows","distributing","the","execution","of","task","instances","to","multiple","worker","nodes",".","Celery","is","a","simple",",","flexible","and","reliable","distributed","system","to","process","vast","amounts","of","messages",",","while","providing","operations","with","the","tools","required","to","maintain","such","a","system","."]
docstr: Handle remnants of tasks that were failed because they were stuck in queued.
  
  Tasks can get stuck in queued. If such a task is detected, it will be marked
  as `UP_FOR_RETRY` if the task instance has remaining retries or marked as `FAILED`
  if it doesn't.
  
  :param tis: List of Task Instances to clean up
  :return: List of readable task instances for a warning message
docstr_tok: ["Handle","remnants","of","tasks","that","were","failed","because","they","were","stuck","in","queued",".","Tasks","can","get","stuck","in","queued",".","If","such","a","task","is","detected",",","it","will","be","marked","as","`","UP_FOR_RETRY","`","if","the","task","instance","has","remaining","retries","or","marked","as","`","FAILED","`","if","it","does","n't",".",":","param","tis",":","List","of","Task","Instances","to","clean","up",":","return",":","List","of","readable","task","instances","for","a","warning","message"]
code: def cleanup_stuck_queued_tasks(
      self, tis: list[TaskInstance]
  ) -> list[str]:
      """
      Handle remnants of tasks that were failed because they were stuck in queued.
  
      Tasks can get stuck in queued. If such a task is detected, it will be marked
      as `UP_FOR_RETRY` if the task instance has remaining retries or marked as `FAILED`
      if it doesn't.
  
      :param tis: List of Task Instances to clean up
      :return: List of readable task instances for a warning message
      """
      readable_tis = []
      from airflow.providers.celery.executors.celery_executor_utils import (
          app,
      )
  
      for ti in tis:
          readable_tis.append(repr(ti))
          task_instance_key = ti.key
          self.fail(task_instance_key, None)
          celery_async_result = self.tasks.pop(task_instance_key, None)
          if celery_async_result:
              try:
                  app.control.revoke(celery_async_result.task_id)
              except Exception as ex:
                  self.log.error(
                      "Error revoking task instance %s from celery: %s",
                      task_instance_key,
                      ex,
                  )
      return readable_tis
  
imports: from __future__ import annotations
  import logging
  import math
  import operator
  import time
  from collections import Counter
  from concurrent.futures import ProcessPoolExecutor
  from multiprocessing import cpu_count
  from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple
  from celery import states
  from airflow.configuration import conf
  from airflow.exceptions import AirflowTaskTimeout
  from airflow.executors.base_executor import BaseExecutor
  from airflow.stats import Stats
  from airflow.utils.state import TaskInstanceState
label_desc: Use image node_id 14 for calling the CeleryExecutor obj's underlying member method code with example usage: obj.cleanup_stuck_queued_tasks(tis) and returns: readable_tis