def _convert_upc_a2e(self, upc_a: str) -> str:
        """Convert a 12-digit UPC-A barcode to its 8-digit UPC-E equivalent.

        .. warning::
           Not all UPC-A barcodes can be converted.
        """
        if not isinstance(upc_a, str):
            raise TypeError("`upc_a` is not a string")
        m1 = self.upc_ae_pattern1.match(upc_a)
        m2 = self.upc_ae_pattern2.match(upc_a)
        m3 = self.upc_ae_pattern3.match(upc_a)
        if not any([m1, m2, m3]):
            raise ValueError("`upc_a` has an invalid value")
        upc_e_template = "{number_system_digit}{mfr_code}{product_code}{extra}{check_digit}"
        if m1:
            upc_e = upc_e_template.format(**m1.groupdict())
        elif m2:
            groupdict: Dict[str, str] = m2.groupdict()
            mfr_code = groupdict.get("mfr_code") or ""
            groupdict["extra"] = str(len(mfr_code))
            upc_e = upc_e_template.format(**groupdict)
        elif m3:
            groupdict = m3.groupdict()
            groupdict["product_code"] = ""
            upc_e = upc_e_template.format(**groupdict)
        return upc_e
Convert a 12-digit UPC-A barcode to its 8-digit UPC-E equivalent.

        .. warning::
           Not all UPC-A barcodes can be converted.
        
faker/providers/barcode/en_US/__init__.py