<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _parse_canonical_dbref(doc):
 """Decode a JSON DBRef to bson.dbref.DBRef."""

    for key in doc:
        if key.startswith('$') and key not in _DBREF_KEYS:
            # Other keys start with $, so dct cannot be parsed as a DBRef.
            return doc
    return DBRef(doc.pop('$ref'), doc.pop('$id'),
                 database=doc.pop('$db', None), **doc)