code: def from_attrs_attribute(attrib, target):
      """Infer a strategy from the metadata on an attr.Attribute object."""
      # Try inferring from the default argument.  Note that this will only help if
      # the user passed `infer` to builds() for this attribute, but in that case
      # we use it as the minimal example.
      default = st.nothing()
      if isinstance(attrib.default, attr.Factory):
          if not attrib.default.takes_self:
              default = st.builds(attrib.default.factory)
      elif attrib.default is not attr.NOTHING:
          default = st.just(attrib.default)
  
      # Try inferring None, exact values, or type from attrs provided validators.
      null = (
          st.nothing()
      )  # updated to none() on seeing an OptionalValidator
      in_collections = (
          []
      )  # list of in_ validator collections to sample from
      validator_types = (
          set()
      )  # type constraints to pass to types_to_strategy()
      if attrib.validator is not None:
          validator = attrib.validator
          if isinstance(validator, attr.validators._OptionalValidator):
              null = st.none()
              validator = validator.validator
          if isinstance(validator, attr.validators._AndValidator):
              vs = validator._validators
          else:
              vs = [validator]
          for v in vs:
              if isinstance(v, attr.validators._InValidator):
                  if isinstance(v.options, string_types):
                      in_collections.append(
                          list(all_substrings(v.options))
                      )
                  else:
                      in_collections.append(v.options)
              elif isinstance(v, attr.validators._InstanceOfValidator):
                  validator_types.add(v.type)
  
      # This is the important line.  We compose the final strategy from various
      # parts.  The default value, if any, is the minimal shrink, followed by
      # None (again, if allowed).  We then prefer to sample from values passed
      # to an in_ validator if available, but infer from a type otherwise.
      # Pick one because (sampled_from((1, 2)) | from_type(int)) would usually
      # fail validation by generating e.g. zero!
      if in_collections:
          sample = st.sampled_from(
              list(ordered_intersection(in_collections))
          )
          strat = default | null | sample
      else:
          strat = (
              default
              | null
              | types_to_strategy(attrib, validator_types)
          )
  
      # Better to give a meaningful error here than an opaque "could not draw"
      # when we try to get a value but have lost track of where this was created.
      if strat.is_empty:
          raise ResolutionFailed(
              "Cannot infer a strategy from the default, validator, type, or "
              "converter for attribute=%r of class=%r"
              % (attrib, target)
          )
      return strat
  
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 2 for calling a global function with example usage: from_attrs_attribute(attrib, target) and returns: strat