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

def decrypt(self, cipher, nonce, pubkey, dehex=False):
        '''
        Return decrypted msg contained in cypher using nonce and shared key
        generated from .key and pubkey.
        If pubkey is hex encoded it is converted first
        If dehex is True then use HexEncoder otherwise use RawEncoder

        Intended for the owner of .key

        cypher is string
        nonce is string
        pub is Publican instance
        '''
        if not isinstance(pubkey, PublicKey):
            if len(pubkey) == 32:
                pubkey = PublicKey(pubkey, encoding.RawEncoder)
            else:
                pubkey = PublicKey(pubkey, encoding.HexEncoder)
        box = Box(self.key, pubkey)
        decoder = encoding.HexEncoder if dehex else encoding.RawEncoder
        if dehex and len(nonce) != box.NONCE_SIZE:
            nonce = decoder.decode(nonce)
        return box.decrypt(cipher, nonce, decoder)