code: def types_to_strategy(attrib, types):
      """Find all the type metadata for this attribute, reconcile it, and infer a
      strategy from the mess."""
      # If we know types from the validator(s), that's sufficient.
      if len(types) == 1:
          (typ,) = types
          if isinstance(typ, tuple):
              return st.one_of(*map(st.from_type, typ))
          return st.from_type(typ)
      elif types:
          # We have a list of tuples of types, and want to find a type
          # (or tuple of types) that is a subclass of all of of them.
          type_tuples = [
              k if isinstance(k, tuple) else (k,) for k in types
          ]
          # Flatten the list, filter types that would fail validation, and
          # sort so that ordering is stable between runs and shrinks well.
          allowed = [
              t
              for t in set(sum(type_tuples, ()))
              if all(issubclass(t, tup) for tup in type_tuples)
          ]
          allowed.sort(key=type_sorting_key)
          return st.one_of([st.from_type(t) for t in allowed])
  
      # Otherwise, try the `type` attribute as a fallback, and finally try
      # the type hints on a converter (desperate!) before giving up.
      if is_a_type(getattr(attrib, "type", None)):
          # The convoluted test is because variable annotations may be stored
          # in string form; attrs doesn't evaluate them and we don't handle them.
          # See PEP 526, PEP 563, and Hypothesis issue #1004 for details.
          return st.from_type(attrib.type)
  
      converter = getattr(attrib, "converter", None)
      if isinstance(converter, type):
          return st.from_type(converter)
      elif callable(converter):
          hints = get_type_hints(converter)
          if "return" in hints:
              return st.from_type(hints["return"])
  
      return st.nothing()
  
file_path: catboost/contrib/python/hypothesis/py2/hypothesis/strategies/_internal/attrs.py
imports: from __future__ import absolute_import, division, print_function
  from functools import reduce
  from itertools import chain
  import attr
  import hypothesis.strategies
  from hypothesis.errors import ResolutionFailed
  from hypothesis.internal.compat import get_type_hints, string_types
  from hypothesis.strategies._internal.types import is_a_type, type_sorting_key
  from hypothesis.utils.conventions import infer
label_desc: Use image node_id 3 for calling a global function with example usage: types_to_strategy(attrib, types) and returns: st, st, st, st, st, st, st