"Ann asked Mary what time the library closes, but she had forgotten." is a true sentence.

Does this mean that "Mary had forgotten."?
yes