
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		bool:
			return credit_card_number.startswith(('34', '35', '37', '4', '5', '6')     )
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		bool:
			lowerCAmelCase__      :      List[str]         =		credit_card_number
			lowerCAmelCase__      :      int         =		0
			lowerCAmelCase__      :      Tuple         =		len(SCREAMING_SNAKE_CASE_     ) - 2
			for i in range(SCREAMING_SNAKE_CASE_       ,							-1       ,							-2     ):
						#  double the value of every second digit
						lowerCAmelCase__      :      Union[str, Any]         =		int(cc_number[i]     )
						digit *= 2
						# If doubling of a number results in a two digit number
						# i.e greater than 9(e.g., 6 × 2 = 12),
						# then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
						# to get a single digit number.
						if digit > 9:
									digit %= 10
									digit += 1
						lowerCAmelCase__      :      int         =		cc_number[:i] + str(SCREAMING_SNAKE_CASE_     ) + cc_number[i + 1 :]
						total += digit

			# Sum up the remaining digits
			for i in range(len(SCREAMING_SNAKE_CASE_     ) - 1       ,							-1       ,							-2     ):
						total += int(cc_number[i]     )

			return total % 10 == 0
def  lowerCAmelCase__			(  SCREAMING_SNAKE_CASE_     )				->		bool:
			lowerCAmelCase__      :      Dict         =		F'''{credit_card_number} is an invalid credit card number because'''
			if not credit_card_number.isdigit():
						print(F'''{error_message} it has nonnumerical characters.'''     )
						return False

			if not 13 <= len(SCREAMING_SNAKE_CASE_     ) <= 16:
						print(F'''{error_message} of its length.'''     )
						return False

			if not validate_initial_digits(SCREAMING_SNAKE_CASE_     ):
						print(F'''{error_message} of its first two digits.'''     )
						return False

			if not luhn_validation(SCREAMING_SNAKE_CASE_     ):
						print(F'''{error_message} it fails the Luhn check.'''     )
						return False

			print(F'''{credit_card_number} is a valid credit card number.'''     )
			return True


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					validate_credit_card_number("""4111111111111111""")
					validate_credit_card_number("""32323""")

from typing import List, Union

from ..utils import (
    add_end_docstrings,
    is_tf_available,
    is_torch_available,
    is_vision_available,
    logging,
    requires_backends,
)
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
					from PIL import Image

					from ..image_utils import load_image

if is_tf_available():
					import tensorflow as tf

					from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
					from ..tf_utils import stable_softmax

if is_torch_available():
					from ..models.auto.modeling_auto import MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING

lowerCamelCase__          =		logging.get_logger(__name__)







@add_end_docstrings(__magic_name__	)
class      A__							(     __magic_name__	):






				def __init__(						self					:      int    ,     *a					:      Dict    ,     **a					:      Union[str, Any]   ):






							'''simple docstring'''







							super().__init__(*a    ,     **a   )
							requires_backends(self    ,     'vision'   )
							self.check_model_type(
							    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
							    if self.framework == 'tf'
							    else MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING   )






				def 							_lowerCamelCase		(						self					:      Dict    ,     a					:      List[str]=None   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Any         =		{}
							if top_k is not None:
										lowerCAmelCase__      :      Tuple         =		top_k
							return {}, {}, postprocess_params






				def __call__(						self					:      Any    ,     a					:      Union[str, List[str], "Image.Image", List["Image.Image"]]    ,     **a					:      List[Any]   ):






							'''simple docstring'''







							return super().__call__(a    ,     **a   )






				def 							_lowerCamelCase		(						self					:      Any    ,     a					:      Optional[Any]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      List[Any]         =		load_image(a   )
							lowerCAmelCase__      :      Optional[int]         =		self.image_processor(images=a    ,     return_tensors=self.framework   )
							return model_inputs






				def 							_lowerCamelCase		(						self					:      Optional[int]    ,     a					:      List[str]   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[Any]         =		self.model(**a   )
							return model_outputs






				def 							_lowerCamelCase		(						self					:      Optional[Any]    ,     a					:      List[Any]    ,     a					:      List[Any]=5   ):






							'''simple docstring'''







							if top_k > self.model.config.num_labels:
										lowerCAmelCase__      :      Optional[int]         =		self.model.config.num_labels

							if self.framework == "pt":
										lowerCAmelCase__      :      List[Any]         =		model_outputs.logits.softmax(-1   )[0]
										lowerCAmelCase__      ,				lowerCAmelCase__      :      Optional[int]         =		probs.topk(a   )
							elif self.framework == "tf":
										lowerCAmelCase__      :      Any         =		stable_softmax(model_outputs.logits    ,     axis=-1   )[0]
										lowerCAmelCase__      :      Any         =		tf.math.top_k(a    ,     k=a   )
										lowerCAmelCase__      ,				lowerCAmelCase__      :      int         =		topk.values.numpy(), topk.indices.numpy()
							else:
										raise ValueError(f'''Unsupported framework: {self.framework}'''   )

							lowerCAmelCase__      :      List[Any]         =		scores.tolist()
							lowerCAmelCase__      :      List[str]         =		ids.tolist()
							return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(a    ,     a   )]