Imitate with Caution: Offline and Online Imitation