San Francisco train operator appears to fall asleep as train nearly derails