<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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