import tensorflow as tf

                ops.update(rnn_params=self._rnn_params)
        for name, op in ops.items():
            tf.add_to_collection(name, op)
        self._initial_state_name = self.with_prefix(self._name, 'initial')
        self._final_state_name = self.with_prefix(self._name, 'final')
        for state_tuple in self._initial_state:
            tf.add_to_collection(self._initial_state_name, state_tuple.c)
            tf.add_to_collection(self._initial_state_name, state_tuple.h)
        for state_tuple in self._final_state:
            tf.add_to_collection(self._final_state_name, state_tuple.c)
            tf.add_to_collection(self._final_state_name, state_tuple.h)


    def import_state_tuples(self, state_tuples, name, num_replicas):
        restored = []
        for i in range(len(state_tuples) * num_replicas):
            c = tf.get_collection_ref(name)[2 * i + 0]
            h = tf.get_collection_ref(name)[2 * i + 1]
            restored.append(tf.contrib.rnn.LSTMStateTuple(c, h))
        return tuple(restored)
