code: def by_relevance(weak=WEAK_MATCHES, strong=STRONG_MATCHES):
      """
      Create a key function that can be used to sort errors by relevance.
  
      Arguments:
          weak (set):
              a collection of validator names to consider to be "weak".
              If there are two errors at the same level of the instance
              and one is in the set of weak validator names, the other
              error will take priority. By default, :validator:`anyOf` and
              :validator:`oneOf` are considered weak validators and will
              be superseded by other same-level validation errors.
  
          strong (set):
              a collection of validator names to consider to be "strong"
      """
  
      def relevance(error):
          validator = error.validator
          return (
              -len(error.path),
              validator not in weak,
              validator in strong,
          )
  
      return relevance
  
imports: from collections import defaultdict, deque
  import itertools
  import pprint
  import textwrap
  import attr
  from jsonschema import _utils
  from jsonschema.compat import PY3, iteritems
label_desc: Use image node_id 1 for calling a global function with example usage: by_relevance(weak, strong) and returns: relevance, unknown,  unknown,  unknown