  from django.utils.formats import get_format
  from django.utils.html import format_html, html_safe
  from django.utils.regex_helper import _lazy_re_compile
  from django.utils.safestring import mark_safe
  from django.utils.topological_sort import CyclicDependencyError, stable_topological_sort
  from django.utils.translation import gettext_lazy as _
  
  from .renderers import get_default_renderer
  
  __all__ = (
 
</s> remove from django.utils.topological_sort import stable_topological_sort
 </s> add  </s> remove         dependency_graph = defaultdict(set)
 </s> add         ts = TopologicalSorter() </s> remove                                 dependency_graph[op].add(op2)

            # we use a stable sort for deterministic tests & general behavior
            self.generated_operations[app_label] = stable_topological_sort(
                ops, dependency_graph
            )
 </s> add                                 ts.add(op, op2)
            self.generated_operations[app_label] = list(ts.static_order())
  from django.utils.formats import get_format
  from django.utils.html import format_html, html_safe
  from django.utils.regex_helper import _lazy_re_compile
  from django.utils.safestring import mark_safe

  from django.utils.translation import gettext_lazy as _
  
  from .renderers import get_default_renderer
  
  __all__ = (
keep keep keep keep replace keep keep keep keep keep
 Fixed #32528 -- Replaced django.utils.topological_sort with graphlib.TopologicalSort().

graphlib.TopologicalSort() is available since Python 3.9. 
django/forms/widgets.py