def METHOD_NAME(cls, key, kwargs: Optional[Dict[str, Any]] = None) -> Writer:
    """Returns a :class:`~nannyml.io.base.Writer` instance for a given string."""
    if kwargs is None:
        kwargs = {}
    if key not in cls.registry:
        raise InvalidArgumentsException(
            f"unknown key '{key}' given. " f"Currently registered keys are: {list(cls.registry.keys())}"
        )
    writer_class = cls.registry[key]
    return writer_class(**kwargs)