code: def _change_mode(self, mode, major, minor):
          
          if self._mode:
              if self._mode != mode:
                  raise RuntimeError('Can\'t change mode (from %s to %s)' % (self._mode, mode))
          self._require_version(major=major, minor=minor)
          self._mode = mode
          # when setting mode, we reset all flags
          self.ticket_flags = YubiKeyConfigBits(0x0)
          self.config_flags = YubiKeyConfigBits(0x0)
          self.extended_flags = YubiKeyConfigBits(0x0)
          if mode != 'YUBIKEY_OTP':
              self.ticket_flag(mode, True)
docs: Change mode of operation, with some sanity checks.