def METHOD_NAME(self, pid):
    """
    This method is invoked whenever a persistent ID is encountered.
    Here, pid is the tuple returned by PmgPickler.
    """
    try:
        type_tag, key_id = pid
    except Exception:
        # Sometimes we get a string such as ('Element', u'C') instead
        # of a real tuple. Use ast to evaluate the expression (much safer
        # than eval).
        import ast
        type_tag, key_id = ast.literal_eval(pid)
    if type_tag == "Element":
        return Element(key_id)
    # Always raises an error if you cannot return the correct object.
    # Otherwise, the unpickler will think None is the object referenced
    # by the persistent ID.
    raise pickle.UnpicklingError(f"unsupported persistent object with pid {pid}")