code: def _c3_mro(cls, abcs=None):
      """Computes the method resolution order using extended C3 linearization.
  
      If no *abcs* are given, the algorithm works exactly like the built-in C3
      linearization used for method resolution.
  
      If given, *abcs* is a list of abstract base classes that should be inserted
      into the resulting MRO. Unrelated ABCs are ignored and don't end up in the
      result. The algorithm inserts ABCs where their functionality is introduced,
      i.e. issubclass(cls, abc) returns True for the class itself but returns
      False for all its direct base classes. Implicit ABCs for a given class
      (either registered or inferred from the presence of a special method like
      __len__) are inserted directly after the last ABC explicitly listed in the
      MRO of said class. If two implicit ABCs end up next to each other in the
      resulting MRO, their ordering depends on the order of types in *abcs*.
  
      """
      for i, base in enumerate(reversed(cls.__bases__)):
          if hasattr(base, "__abstractmethods__"):
              boundary = len(cls.__bases__) - i
              break  # Bases up to the last explicit ABC are considered first.
      else:
          boundary = 0
      abcs = list(abcs) if abcs else []
      explicit_bases = list(cls.__bases__[:boundary])
      abstract_bases = []
      other_bases = list(cls.__bases__[boundary:])
      for base in abcs:
          if issubclass(cls, base) and not any(
              issubclass(b, base) for b in cls.__bases__
          ):
              # If *cls* is the class that introduces behaviour described by
              # an ABC *base*, insert said ABC to its MRO.
              abstract_bases.append(base)
      for base in abstract_bases:
          abcs.remove(base)
      explicit_c3_mros = [
          _c3_mro(base, abcs=abcs) for base in explicit_bases
      ]
      abstract_c3_mros = [
          _c3_mro(base, abcs=abcs) for base in abstract_bases
      ]
      other_c3_mros = [_c3_mro(base, abcs=abcs) for base in other_bases]
      return _c3_merge(
          [[cls]]
          + explicit_c3_mros
          + abstract_c3_mros
          + other_c3_mros
          + [explicit_bases]
          + [abstract_bases]
          + [other_bases]
      )
  
imports: from abc import get_cache_token
  from collections import namedtuple
  from reprlib import recursive_repr
  from _thread import RLock
label_desc: Use image node_id 24 for calling a global function with example usage: _c3_mro(cls, abcs) and returns: _c3_merge