def METHOD_NAME(tag):
    """
    A decorator which allows for serializing/deserializing a class as a YAML mapping (dictionary).
    The class must be able to be constructed with `**kwargs` to set its data.
    :param tag: The tag to use for the type (e.g. `!MyTag`)
    :type tag: str
    """
    def decorator(obj_class):
        def construct(loader, node):
            try:
                attrs = loader.construct_mapping(node)
                instance = obj_class(**attrs)
                return instance
            except yaml.constructor.ConstructorError:
                return obj_class()
        def represent(dumper, data):
            items = data.items() if hasattr(data, "items") else data.__dict__.items()
            attrs = {key: value for key, value in items if value is not Undefined}
            return dumper.represent_mapping(tag, attrs)
        yaml.add_constructor(tag, construct, Loader=Loader)
        yaml.add_representer(obj_class, represent, Dumper=Dumper)
        return obj_class
    return decorator