Network Inversion and Its Applications