<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def with_optimizer_tensor(self, tensor: Union[tf.Tensor, tf.Operation]) -> 'Optimization': """ Replace optimizer tensor. :param model: Tensorflow tensor. :return: Optimization instance self reference. """

        self._optimizer_tensor = tensor
        return self