code: def _asdict_anything(
      val,
      filter,
      dict_factory,
      retain_collection_types,
      value_serializer,
  ):
      """
      ``asdict`` only works on attrs instances, this works on anything.
      """
      if getattr(val.__class__, "__attrs_attrs__", None) is not None:
          # Attrs class.
          rv = asdict(
              val,
              True,
              filter,
              dict_factory,
              retain_collection_types,
              value_serializer,
          )
      elif isinstance(val, (tuple, list, set, frozenset)):
          cf = (
              val.__class__ if retain_collection_types is True else list
          )
          rv = cf(
              [
                  _asdict_anything(
                      i,
                      filter,
                      dict_factory,
                      retain_collection_types,
                      value_serializer,
                  )
                  for i in val
              ]
          )
      elif isinstance(val, dict):
          df = dict_factory
          rv = df(
              (
                  _asdict_anything(
                      kk,
                      filter,
                      df,
                      retain_collection_types,
                      value_serializer,
                  ),
                  _asdict_anything(
                      vv,
                      filter,
                      df,
                      retain_collection_types,
                      value_serializer,
                  ),
              )
              for kk, vv in iteritems(val)
          )
      else:
          rv = val
          if value_serializer is not None:
              rv = value_serializer(None, None, rv)
  
      return rv
  
file_path: catboost/contrib/python/attrs/py2/attr/_funcs.py
imports: from __future__ import absolute_import, division, print_function
  import copy
  from ._compat import iteritems
  from ._make import NOTHING, _obj_setattr, fields
  from .exceptions import AttrsAttributeNotFoundError
label_desc: Use image node_id 2 for calling a global function with example usage: _asdict_anything(val, filter, dict_factory, retain_collection_types, value_serializer) and returns: rv