docs: def _check_nested_callables(dictionary, object_name):
    """Checks if all items in the dictionary and in subdictionaries are callables.
  
    Args:
      dictionary: Dictionary of callables or other dictionaries with callables.
      object_name: The name of the object that is expected in the dictionary.
        E.g. 'Initializer', 'Partitioner' or 'Regularizer'. The first letter
        should be capitalised as this will be the first word in the error message.
  
    Raises:
      TypeError: If the dictionary contains something that is not either a
        dictionary or a callable.
    """
    for key, entry in six.iteritems(dictionary):
      if hasattr(entry, "items"):
        _check_nested_callables(entry, object_name)
      elif not callable(entry):
        raise TypeError(
            "{} for '{}' is not a callable function or dictionary"
            .format(object_name, key))