code: def _dehex(s):
      
      import re
      import binascii
  
      # Remove all non-hexadecimal digits
      s = re.sub(br'[^a-fA-F\d]', b'', s)
      # binscii.unhexlify works in Python 2 and Python 3 (unlike
      # thing.decode('hex')).
      return binascii.unhexlify(s)
docs: Liberally convert from hex string to binary string.