




import inspect

import jax
import jax.lax as lax
import jax.numpy as jnp

from ..utils import add_start_docstrings
from ..utils.logging import get_logger


SCREAMING_SNAKE_CASE:     Union[str, Any]									= get_logger(__name__)


SCREAMING_SNAKE_CASE:     Union[str, Any]									= r'''
    Args:
        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary.

            Indices can be obtained using [`PreTrainedTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are input IDs?](../glossary#input-ids)
        scores (`jnp.ndarray` of shape `(batch_size, config.vocab_size)`):
            Prediction scores of a language modeling head. These can be logits for each vocabulary when not using beam
            search or log softmax for each vocabulary token when using beam search
        kwargs (`Dict[str, Any]`, *optional*):
            Additional logits processor specific kwargs.

    Return:
        `jnp.ndarray` of shape `(batch_size, config.vocab_size)`: The processed prediction scores.

'''



class    lowercase_		:



						@add_start_docstrings(snake_case__  )
						def __call__(			self	:   List[Any]					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray  ):

								"""simple docstring"""

								raise NotImplementedError(
								    f'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''  )



class    lowercase_		:



						@add_start_docstrings(snake_case__  )
						def __call__(			self	:   str					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray  ):

								"""simple docstring"""

								raise NotImplementedError(
								    f'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''  )



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						@add_start_docstrings(snake_case__  )
						def __call__(			self	:   Dict					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int					,							**snake_case__	:   Tuple  ):

								"""simple docstring"""

								for processor in self:
										SCREAMING_SNAKE_CASE_					      =							inspect.signature(processor.__call__  ).parameters
										if len(snake_case__  ) > 3:
												if not all(arg in kwargs for arg in list(function_args.keys()  )[2:]  ):
														raise ValueError(
														    f'''Make sure that all the required parameters: {list(function_args.keys()  )} for '''
														    f'''{processor.__class__} are passed to the logits processor.'''  )
												SCREAMING_SNAKE_CASE_					      =							processor(snake_case__					,							snake_case__					,							snake_case__					,							**snake_case__  )
										else:
												SCREAMING_SNAKE_CASE_					      =							processor(snake_case__					,							snake_case__					,							snake_case__  )
								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Tuple					,							snake_case__	:   float  ):

								"""simple docstring"""

								if not isinstance(snake_case__					,							snake_case__  ) or not (temperature > 0):
										raise ValueError(f'''`temperature` has to be a strictly positive float, but is {temperature}'''  )

								SCREAMING_SNAKE_CASE_					      =							temperature






						def __call__(			self	:   Union[str, Any]					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							scores / self.temperature
								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   List[str]					,							snake_case__	:   float					,							snake_case__	:   float = -float('Inf'  )					,							snake_case__	:   int = 1  ):

								"""simple docstring"""

								if not isinstance(snake_case__					,							snake_case__  ) or (top_p < 0 or top_p > 1.0):
										raise ValueError(f'''`top_p` has to be a float > 0 and < 1, but is {top_p}'''  )
								if not isinstance(snake_case__					,							snake_case__  ) or (min_tokens_to_keep < 1):
										raise ValueError(f'''`min_tokens_to_keep` has to be a positive integer, but is {min_tokens_to_keep}'''  )

								SCREAMING_SNAKE_CASE_					      =							top_p
								SCREAMING_SNAKE_CASE_					      =							filter_value
								SCREAMING_SNAKE_CASE_					      =							min_tokens_to_keep






						def __call__(			self	:   str					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_      ,				SCREAMING_SNAKE_CASE_					      =							lax.top_k(snake_case__					,							scores.shape[-1]  )

								SCREAMING_SNAKE_CASE_					      =							jnp.full_like(snake_case__					,							self.filter_value  )
								SCREAMING_SNAKE_CASE_					      =							jax.nn.softmax(snake_case__					,							axis=-1  ).cumsum(axis=-1  )
								SCREAMING_SNAKE_CASE_					      =							cumulative_probs < self.top_p

								# include the token that is higher than top_p as well
								SCREAMING_SNAKE_CASE_					      =							jnp.roll(snake_case__					,							1  )
								score_mask |= score_mask.at[:, 0].set(snake_case__  )

								# min tokens to keep
								SCREAMING_SNAKE_CASE_					      =							score_mask.at[:, : self.min_tokens_to_keep].set(snake_case__  )

								SCREAMING_SNAKE_CASE_					      =							jnp.where(snake_case__					,							snake_case__					,							snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							jax.lax.sort_key_val(snake_case__					,							snake_case__  )[-1]

								return next_scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Union[str, Any]					,							snake_case__	:   int					,							snake_case__	:   float = -float('Inf'  )					,							snake_case__	:   int = 1  ):

								"""simple docstring"""

								if not isinstance(snake_case__					,							snake_case__  ) or top_k <= 0:
										raise ValueError(f'''`top_k` has to be a strictly positive integer, but is {top_k}'''  )

								SCREAMING_SNAKE_CASE_					      =							max(snake_case__					,							snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							filter_value






						def __call__(			self	:   Optional[Any]					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_      ,				SCREAMING_SNAKE_CASE_					      =							scores.shape
								SCREAMING_SNAKE_CASE_					      =							jnp.full(batch_size * vocab_size					,							self.filter_value  )

								SCREAMING_SNAKE_CASE_					      =							min(self.top_k					,							scores.shape[-1]  )  # Safety check
								SCREAMING_SNAKE_CASE_      ,				SCREAMING_SNAKE_CASE_					      =							lax.top_k(snake_case__					,							snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							jnp.broadcast_to((jnp.arange(snake_case__  ) * vocab_size)[:, None]					,							(batch_size, topk)  ).flatten()
								SCREAMING_SNAKE_CASE_					      =							topk_scores.flatten()
								SCREAMING_SNAKE_CASE_					      =							topk_indices.flatten() + shift

								SCREAMING_SNAKE_CASE_					      =							next_scores_flat.at[topk_indices_flat].set(snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							next_scores_flat.reshape(snake_case__					,							snake_case__  )
								return next_scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   List[str]					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							bos_token_id






						def __call__(			self	:   int					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							jnp.full(scores.shape					,							-float('inf'  )  )

								SCREAMING_SNAKE_CASE_					      =							1 - jnp.bool_(cur_len - 1  )

								SCREAMING_SNAKE_CASE_					      =							jnp.where(snake_case__					,							new_scores.at[:, self.bos_token_id].set(0  )					,							snake_case__  )

								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   List[Any]					,							snake_case__	:   int					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							max_length
								SCREAMING_SNAKE_CASE_					      =							eos_token_id






						def __call__(			self	:   Optional[int]					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							jnp.full(scores.shape					,							-float('inf'  )  )

								SCREAMING_SNAKE_CASE_					      =							1 - jnp.bool_(cur_len - self.max_length + 1  )

								SCREAMING_SNAKE_CASE_					      =							jnp.where(snake_case__					,							new_scores.at[:, self.eos_token_id].set(0  )					,							snake_case__  )

								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Optional[int]					,							snake_case__	:   int					,							snake_case__	:   int  ):

								"""simple docstring"""

								if not isinstance(snake_case__					,							snake_case__  ) or min_length < 0:
										raise ValueError(f'''`min_length` has to be a positive integer, but is {min_length}'''  )

								if not isinstance(snake_case__					,							snake_case__  ) or eos_token_id < 0:
										raise ValueError(f'''`eos_token_id` has to be a positive integer, but is {eos_token_id}'''  )

								SCREAMING_SNAKE_CASE_					      =							min_length
								SCREAMING_SNAKE_CASE_					      =							eos_token_id






						def __call__(			self	:   int					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							1 - jnp.clip(cur_len - self.min_length					,							0					,							1  )

								SCREAMING_SNAKE_CASE_					      =							jnp.where(snake_case__					,							scores.at[:, self.eos_token_id].set(-float('inf'  )  )					,							snake_case__  )

								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Any					,							snake_case__	:   Optional[int]					,							snake_case__	:   Tuple  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							list(snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							begin_index






						def __call__(			self	:   Tuple					,							snake_case__	:   Optional[int]					,							snake_case__	:   int					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							1 - jnp.bool_(cur_len - self.begin_index  )

								SCREAMING_SNAKE_CASE_					      =							jnp.where(snake_case__					,							scores.at[:, self.begin_suppress_tokens].set(-float('inf'  )  )					,							snake_case__  )

								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Dict					,							snake_case__	:   list  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							list(snake_case__  )






						def __call__(			self	:   str					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							scores.at[..., self.suppress_tokens].set(-float('inf'  )  )

								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Any					,							snake_case__	:   Optional[int]  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							dict(snake_case__  )
								# Converts the dictionary of format {index: token} containing the tokens to be forced to an array, where the
								# index of the array corresponds to the index of the token to be forced, for XLA compatibility.
								# Indexes without forced tokens will have a negative value.
								SCREAMING_SNAKE_CASE_					      =							jnp.ones((max(force_token_map.keys()  ) + 1)					,							dtype=jnp.intaa  ) * -1
								for index, token in force_token_map.items():
										if token is not None:
												SCREAMING_SNAKE_CASE_					      =							force_token_array.at[index].set(snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							jnp.intaa(snake_case__  )






						def __call__(			self	:   Union[str, Any]					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   jnp.ndarray					,							snake_case__	:   int  ):

								"""simple docstring"""

								def _force_token(snake_case__	:   Dict  ):
										SCREAMING_SNAKE_CASE_					      =							scores.shape[0]
										SCREAMING_SNAKE_CASE_					      =							self.force_token_array[generation_idx]

										SCREAMING_SNAKE_CASE_					      =							jnp.ones_like(snake_case__					,							dtype=scores.dtype  ) * -float('inf'  )
										SCREAMING_SNAKE_CASE_					      =							jnp.zeros((batch_size, 1)					,							dtype=scores.dtype  )
										SCREAMING_SNAKE_CASE_					      =							lax.dynamic_update_slice(snake_case__					,							snake_case__					,							(0, current_token)  )
										return new_scores

								SCREAMING_SNAKE_CASE_					      =							lax.cond(
								    cur_len >= self.force_token_array.shape[0]					,							lambda: scores					,							lambda: lax.cond(
								        self.force_token_array[cur_len] >= 0					,							lambda: _force_token(snake_case__  )					,							lambda: scores					,							)					,							)
								return scores



class    lowercase_		(SCREAMING_SNAKE_CASE__ ):



						def __init__(			self	:   Optional[int]					,							snake_case__	:   Optional[int]					,							snake_case__	:   List[Any]					,							snake_case__	:   Optional[Any]  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							generate_config.eos_token_id
								SCREAMING_SNAKE_CASE_					      =							generate_config.no_timestamps_token_id
								SCREAMING_SNAKE_CASE_					      =							generate_config.no_timestamps_token_id + 1

								SCREAMING_SNAKE_CASE_					      =							decoder_input_length + 1

								if generate_config.is_multilingual:
										# room for language token and task token
										self.begin_index += 2
								if hasattr(snake_case__					,							'max_initial_timestamp_index'  ):
										SCREAMING_SNAKE_CASE_					      =							generate_config.max_initial_timestamp_index
								else:
										SCREAMING_SNAKE_CASE_					      =							model_config.vocab_size
								if self.max_initial_timestamp_index is None:
										SCREAMING_SNAKE_CASE_					      =							model_config.vocab_size






						def __call__(			self	:   List[Any]					,							snake_case__	:   Tuple					,							snake_case__	:   List[str]					,							snake_case__	:   Optional[Any]  ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_					      =							scores.at[:, self.no_timestamps_token_id].set(-float('inf'  )  )

								def handle_pairs(snake_case__	:   List[str]					,							snake_case__	:   Optional[int]  ):
										SCREAMING_SNAKE_CASE_					      =							jnp.where((cur_len - self.begin_index) >= 1					,							snake_case__					,							snake_case__  )
										SCREAMING_SNAKE_CASE_					      =							jnp.where(
										    input_ids_k[cur_len - 1] >= self.timestamp_begin					,							True and last_was_timestamp					,							snake_case__					,							)

										SCREAMING_SNAKE_CASE_					      =							jnp.where((cur_len - self.begin_index) < 2					,							snake_case__					,							snake_case__  )
										SCREAMING_SNAKE_CASE_					      =							jnp.where(
										    input_ids_k[cur_len - 2] >= self.timestamp_begin					,							snake_case__					,							snake_case__					,							)

										return jnp.where(
										    snake_case__					,							jnp.where(
										        penultimate_was_timestamp > 0					,							scores_k.at[self.timestamp_begin :].set(-float('inf'  )  )					,							scores_k.at[: self.eos_token_id].set(-float('inf'  )  )					,							)					,							snake_case__					,							)

								SCREAMING_SNAKE_CASE_					      =							jax.vmap(snake_case__  )(snake_case__					,							snake_case__  )

								SCREAMING_SNAKE_CASE_					      =							jnp.where(cur_len == self.begin_index					,							snake_case__					,							snake_case__  )
								SCREAMING_SNAKE_CASE_					      =							jnp.where(
								    self.max_initial_timestamp_index is not None					,							True and apply_max_initial_timestamp					,							snake_case__					,							)

								SCREAMING_SNAKE_CASE_					      =							self.timestamp_begin + self.max_initial_timestamp_index

								SCREAMING_SNAKE_CASE_					      =							jnp.where(
								    snake_case__					,							scores.at[:, last_allowed + 1 :].set(-float('inf'  )  )					,							snake_case__					,							)

								# if sum of probability over timestamps is above any other token, sample timestamp
								SCREAMING_SNAKE_CASE_					      =							jax.nn.log_softmax(snake_case__					,							axis=-1  )

								def handle_cumulative_probs(snake_case__	:   Optional[int]					,							snake_case__	:   Any  ):
										SCREAMING_SNAKE_CASE_					      =							jax.nn.logsumexp(logprobs_k[self.timestamp_begin :]					,							axis=-1  )
										SCREAMING_SNAKE_CASE_					      =							jnp.max(logprobs_k[: self.timestamp_begin]  )
										return jnp.where(
										    timestamp_logprob > max_text_token_logprob					,							scores_k.at[: self.timestamp_begin].set(-float('inf'  )  )					,							snake_case__					,							)

								SCREAMING_SNAKE_CASE_					      =							jax.vmap(snake_case__  )(snake_case__					,							snake_case__  )

								return scores





from collections import defaultdict


def 					_a							(					lowerCAmelCase    ,						lowerCAmelCase )->	bool:
		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(lowerCAmelCase ) != len(lowerCAmelCase ):
				return False

		# Default values for count should be 0
		SCREAMING_SNAKE_CASE_					      =							defaultdict(lowerCAmelCase )

		# For each character in input strings,
		# increment count in the corresponding
		for i in range(len(lowerCAmelCase ) ):
				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()
						SCREAMING_SNAKE_CASE:     Dict									= input('''Enter the first string ''').strip()
						SCREAMING_SNAKE_CASE:     str									= input('''Enter the second string ''').strip()

						SCREAMING_SNAKE_CASE:     Optional[Any]									= check_anagrams(input_a, input_b)
						print(f"""{input_a} and {input_b} are {'' if status else 'not '}anagrams.""")