<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_outputs(self, index, sighash_type):
        '''BIP143 hashOutputs implementation

        Args:
            index        (int): index of input being signed
            sighash_type (int): SIGHASH_SINGLE or SIGHASH_ALL
        Returns:
            (bytes): the hashOutputs, a 32 byte hash
        '''
        if sighash_type == shared.SIGHASH_ALL:
            # If the sighash type is ALL,
            # hashOutputs is the double SHA256 of all output amounts
            # paired up with their scriptPubKey;
            outputs = ByteData()
            for tx_out in self.tx_outs:
                outputs += tx_out.to_bytes()
            return utils.hash256(outputs.to_bytes())
        elif (sighash_type == shared.SIGHASH_SINGLE
              and index < len(self.tx_outs)):
            # if sighash type is SINGLE
            # and the input index is smaller than the number of outputs,
            # hashOutputs is the double SHA256 of the output at the same index
            return utils.hash256(self.tx_outs[index].to_bytes())
        else:
            # Otherwise, hashOutputs is a uint256 of 0x0000......0000
            raise NotImplementedError(
                'I refuse to implement the SIGHASH_SINGLE bug.')