<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def logout(self, subject):
 """ Logs out the specified Subject from the system. Note that most application developers should not call this method unless they have a good reason for doing so. The preferred way to logout a Subject is to call ``Subject.logout()``, not by calling ``SecurityManager.logout`` directly. However, framework developers might find calling this method directly useful in certain cases. :param subject the subject to log out: :type subject: subject_abcs.Subject """

        if (subject is None):
            msg = "Subject argument cannot be None."
            raise ValueError(msg)

        self.before_logout(subject)

        identifiers = copy.copy(subject.identifiers)   # copy is new to yosai
        if (identifiers):
            msg = ("Logging out subject with primary identifier {0}".format(
                   identifiers.primary_identifier))
            logger.debug(msg)

        try:
            # this removes two internal attributes from the session:
            self.delete(subject)
        except Exception:
            msg = "Unable to cleanly unbind Subject.  Ignoring (logging out)."
            logger.debug(msg, exc_info=True)

        finally:
            try:
                self.stop_session(subject)
            except Exception:
                msg2 = ("Unable to cleanly stop Session for Subject. "
                        "Ignoring (logging out).")
                logger.debug(msg2, exc_info=True)