docs: def wrap_kwargs_to_initdict(init_kwargs_fn: InitKwargsFnType,
                              typename: str,
                              check_result: bool = True) \
          -> InstanceToInitDictFnType:
      """
      Wraps a function producing a ``KwargsDict``, making it into a function
      producing an ``InitDict``.
      """
      def wrapper(obj: Instance) -> InitDict:
          result = init_kwargs_fn(obj)
          if check_result:
              if not isinstance(result, dict):
                  raise ValueError(
                      "Class {} failed to provide a kwargs dict and "
                      "provided instead: {}".format(typename, repr(result)))
          return kwargs_to_initdict(init_kwargs_fn(obj))
  
      return wrapper