






"""simple docstring"""



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

__A		:       Union[str, Any]  				=		logging.get_logger(__name__)





@add_end_docstrings(__a							)
class 					_UpperCAmelCase       ( __a							):




					def __init__(				self     :						int    ,						*A     :						List[str]    ,						**A     :						int   )  ->  Optional[Any]:
							super().__init__(*lowerCAmelCase__    ,						**lowerCAmelCase__   )
							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   A  (				self     :						Optional[int]    ,						A     :						Optional[Any]=None   )  ->  List[Any]:
							lowercase_ : Dict							       =   {}
							if top_k is not None:
									lowercase_ : Union[str, Any]							       =   top_k
							return {}, {}, postprocess_params




					def __call__(				self     :						Optional[Any]    ,						A     :						Tuple    ,						**A     :						Tuple   )  ->  str:
							return super().__call__(lowerCAmelCase__    ,						**lowerCAmelCase__   )




					def   A  (				self     :						Any    ,						A     :						Optional[Any]   )  ->  List[str]:
							lowercase_ : str							       =   load_image(lowerCAmelCase__   )
							lowercase_ : Optional[int]							       =   self.image_processor(images=lowerCAmelCase__    ,						return_tensors=self.framework   )
							return model_inputs




					def   A  (				self     :						str    ,						A     :						Optional[Any]   )  ->  List[str]:
							lowercase_ : Union[str, Any]							       =   self.model(**lowerCAmelCase__   )
							return model_outputs






					def   A  (				self     :						Union[str, Any]    ,						A     :						List[str]    ,						A     :						int=5   )  ->  List[Any]:
							if top_k > self.model.config.num_labels:
									lowercase_ : List[str]							       =   self.model.config.num_labels

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

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





"""simple docstring"""





from collections import defaultdict



def 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_				):
		__SCREAMING_SNAKE_CASE            = first_str.lower().strip()
		__SCREAMING_SNAKE_CASE            = second_str.lower().strip()

		# Remove whitespace
		__SCREAMING_SNAKE_CASE            = first_str.replace(""" """  ,				""""""				)
		__SCREAMING_SNAKE_CASE            = second_str.replace(""" """  ,				""""""				)

		# Strings of different lengths are not anagrams
		if len(UpperCamelCase_				) != len(UpperCamelCase_				):
				return False

		# Default values for count should be 0
		__SCREAMING_SNAKE_CASE            = defaultdict(UpperCamelCase_				)

		# For each character in input strings,
		# increment count in the corresponding
		for i in range(len(UpperCamelCase_				)				):
				count[first_str[i]] += 1
				count[second_str[i]] -= 1

		return all(_count == 0 for _count in count.values()				)


if __name__ == "__main__":
							from doctest import testmod

							testmod()
							__magic_name__       =			input("Enter the first string ").strip()
							__magic_name__       =			input("Enter the second string ").strip()

							__magic_name__       =			check_anagrams(input_a, input_b)
							print(F"""{input_a} and {input_b} are {"" if status else "not "}anagrams.""")




