<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _hash_sequence(self, sighash_type, anyone_can_pay):
        '''BIP143 hashSequence implementation

        Args:
            sighash_type    (int): SIGHASH_SINGLE or SIGHASH_ALL
            anyone_can_pay (bool): true if ANYONECANPAY should be set
        Returns:
            (bytes): the hashSequence, a 32 byte hash
        '''
        if anyone_can_pay or sighash_type == shared.SIGHASH_SINGLE:
            # If any of ANYONECANPAY, SINGLE sighash type is set,
            # hashSequence is a uint256 of 0x0000......0000.
            return b'\x00' * 32
        else:
            # hashSequence is the double SHA256 of nSequence of all inputs;
            sequences = ByteData()
            for tx_in in self.tx_ins:
                sequences += tx_in.sequence
            return utils.hash256(sequences.to_bytes())