If a waiter in a restaurant says, “The spaghetti left without paying”, he is using a metaphor.
He is using metonymy-spaghetti representing the person who ate it.