def _upc_ae(self, base: Optional[str] = None, number_system_digit: Optional[int] = None) -> str:
        """Create a 12-digit UPC-A barcode that can be converted to UPC-E.

        The expected value of ``base`` is a 6-digit string. If any other value
        is provided, this method will use a random 6-digit string instead.

        The expected value of ``number_system_digit`` is the integer ``0`` or
        ``1``. If any other value is provided, this method will randomly choose
        from the two.

        Please also view notes on |EnUsBarcodeProvider.upc_a| and
        |EnUsBarcodeProvider.upc_e| for more details.
        """
        base_ = (
            [int(x) for x in base]
            if isinstance(base, str) and self.upc_e_base_pattern.match(base)
            else [self.random_int(0, 9) for _ in range(6)]
        )
        if number_system_digit not in [0, 1]:
            number_system_digit = self.random_int(0, 1)

        if base_[-1] <= 2:
            code = base_[:2] + base_[-1:] + [0] * 4 + base_[2:-1]
        elif base_[-1] <= 4:
            code = base_[: base_[-1]] + [0] * 5 + base_[base_[-1] : -1]
        else:
            code = base_[:5] + [0] * 4 + base_[-1:]

        code.insert(0, number_system_digit)
        weights = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]
        weighted_sum = sum(x * y for x, y in zip(code, weights))
        check_digit = (10 - weighted_sum % 10) % 10
        code.append(check_digit)
        return "".join(str(x) for x in code)
Create a 12-digit UPC-A barcode that can be converted to UPC-E.

        The expected value of ``base`` is a 6-digit string. If any other value
        is provided, this method will use a random 6-digit string instead.

        The expected value of ``number_system_digit`` is the integer ``0`` or
        ``1``. If any other value is provided, this method will randomly choose
        from the two.

        Please also view notes on |EnUsBarcodeProvider.upc_a| and
        |EnUsBarcodeProvider.upc_e| for more details.
        
faker/providers/barcode/en_US/__init__.py