def METHOD_NAME(cls, data) -> M:
    kwargs = data.copy()
    klass = cls.msg_types[kwargs.pop('msg_id')]
    for field_ in fields(klass):
        if is_dataclass(field_.type):
            kwargs[field_.name] = field_.type.METHOD_NAME(kwargs[field_.name])
    return klass(**kwargs)