From my understanding, (SPOILER)the premise of the movie is Emily Browning's character is taken to a mental institution for witnessing something... bad. During her stay there, she comes to learn that she is going to be subjected to a lobotomy unless she can escape. At the same time (or shortly before this) she creates an elaborate fantasy world (which explains the presence of dragons, samurai, and the five lead female's ability to fight somewhat supernaturally). The two worlds collide in a way where they learn things in the fantasy world and use them to escape in the real world.

Speculative though as I don't know much about the movie itself.