code: def _c3_merge(sequences):
      """Merges MROs in *sequences* to a single MRO using the C3 algorithm.
  
      Adapted from http://www.python.org/download/releases/2.3/mro/.
  
      """
      result = []
      while True:
          sequences = [
              s for s in sequences if s
          ]  # purge empty sequences
          if not sequences:
              return result
          for s1 in sequences:  # find merge candidates among seq heads
              candidate = s1[0]
              for s2 in sequences:
                  if candidate in s2[1:]:
                      candidate = None
                      break  # reject the current head, it appears later
              else:
                  break
          if candidate is None:
              raise RuntimeError("Inconsistent hierarchy")
          result.append(candidate)
          # remove the chosen candidate
          for seq in sequences:
              if seq[0] == candidate:
                  del seq[0]
  
file_path: catboost/contrib/deprecated/python/singledispatch/singledispatch/__init__.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from weakref import WeakKeyDictionary
  from .helpers import MappingProxyType, get_cache_token, get_type_hints, update_wrapper
label_desc: Use image node_id 1 for calling a global function with example usage: _c3_merge(sequences) and returns: result