code: def normalize(vat_id):
      
  
      if not vat_id:
          return None
  
      if not isinstance(vat_id, str_cls):
          raise ValueError('VAT ID is not a string')
  
      if len(vat_id) < 3:
          raise ValueError('VAT ID must be at least three character long')
  
      # Normalize the ID for simpler regexes
      vat_id = re.sub('\\s+', '', vat_id)
      vat_id = vat_id.replace('-', '')
      vat_id = vat_id.replace('.', '')
      vat_id = vat_id.upper()
  
      country_prefix = vat_id[0:2]
  
      # Fix people using GR prefix for Greece
      if country_prefix == 'GR':
          vat_id = 'EL' + vat_id[2:]
          country_prefix = 'EL'
  
      if country_prefix not in ID_PATTERNS:
          return None
  
      return vat_id
docs: Accepts a VAT ID and normaizes it, getting rid of spaces, periods, dashes
      etc and converting it to upper case.
  
      :param vat_id:
          The VAT ID to check. Allows "GR" prefix for Greece, even though it
          should be "EL".
  
      :raises:
          ValueError - If the is not a string or is not in the format of two characters plus an identifier
  
      :return:
          None if the VAT ID is blank or not for an EU country or Norway
          Otherwise a normalized string containing the VAT ID