def decode_ast(registry, ast_json):
    """JSON decoder for BaseNodes"""
    if ast_json.get("@type"):
        subclass = registry.get_cls(ast_json["@type"], tuple(ast_json["@fields"]))
        return subclass(
            ast_json["children"],
            ast_json["field_references"],
            ast_json["label_references"],
            position=ast_json["@position"],
        )
    else:
        return ast_json
JSON decoder for BaseNodes