<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def peek(self, deserialized_tx):
 """Peeks into first tx and sets self attrs or raise. """

        self.batch_id = deserialized_tx.object.batch_id
        self.prev_batch_id = deserialized_tx.object.prev_batch_id
        self.producer = deserialized_tx.object.producer
        if self.batch_history.exists(batch_id=self.batch_id):
            raise BatchAlreadyProcessed(
                f"Batch {self.batch_id} has already been processed"
            )
        if self.prev_batch_id != self.batch_id:
            if not self.batch_history.exists(batch_id=self.prev_batch_id):
                raise InvalidBatchSequence(
                    f"Invalid import sequence. History does not exist for prev_batch_id. "
                    f"Got file='{self.filename}', prev_batch_id="
                    f"{self.prev_batch_id}, batch_id={self.batch_id}."
                )