





'''simple docstring'''






import unittest

import numpy as np

from transformers import BertConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
      from transformers.models.bert.modeling_flax_bert import (
          FlaxBertForMaskedLM,
          FlaxBertForMultipleChoice,
          FlaxBertForNextSentencePrediction,
          FlaxBertForPreTraining,
          FlaxBertForQuestionAnswering,
          FlaxBertForSequenceClassification,
          FlaxBertForTokenClassification,
          FlaxBertModel,
      )







class 		UpperCAmelCase   (				unittest.TestCase):


  """simple docstring"""







  def __init__(				self    :					List[Any]							,	UpperCamelCase__    :					List[Any]							,	UpperCamelCase__    :					Union[str, Any]=13							,	UpperCamelCase__    :					Any=7							,	UpperCamelCase__    :					int=True							,	UpperCamelCase__    :					Dict=True							,	UpperCamelCase__    :					Optional[int]=True							,	UpperCamelCase__    :					int=True							,	UpperCamelCase__    :					Any=99							,	UpperCamelCase__    :					Union[str, Any]=32							,	UpperCamelCase__    :					List[str]=5							,	UpperCamelCase__    :					int=4							,	UpperCamelCase__    :					Any=37							,	UpperCamelCase__    :					Union[str, Any]="gelu"							,	UpperCamelCase__    :					Union[str, Any]=0.1							,	UpperCamelCase__    :					Optional[int]=0.1							,	UpperCamelCase__    :					Optional[int]=512							,	UpperCamelCase__    :					List[str]=16							,	UpperCamelCase__    :					Dict=2							,	UpperCamelCase__    :					List[Any]=0.02							,	UpperCamelCase__    :					str=4							,	)     ->						Optional[Any]:
    _UpperCamelCase       			=parent
    _UpperCamelCase       			=batch_size
    _UpperCamelCase       			=seq_length
    _UpperCamelCase       			=is_training
    _UpperCamelCase       			=use_attention_mask
    _UpperCamelCase       			=use_token_type_ids
    _UpperCamelCase       			=use_labels
    _UpperCamelCase       			=vocab_size
    _UpperCamelCase       			=hidden_size
    _UpperCamelCase       			=num_hidden_layers
    _UpperCamelCase       			=num_attention_heads
    _UpperCamelCase       			=intermediate_size
    _UpperCamelCase       			=hidden_act
    _UpperCamelCase       			=hidden_dropout_prob
    _UpperCamelCase       			=attention_probs_dropout_prob
    _UpperCamelCase       			=max_position_embeddings
    _UpperCamelCase       			=type_vocab_size
    _UpperCamelCase       			=type_sequence_label_size
    _UpperCamelCase       			=initializer_range
    _UpperCamelCase       			=num_choices


  def   UpperCamelCase__      (				self    :					Optional[Any]  )     ->						Optional[Any]:
    _UpperCamelCase       			=ids_tensor([self.batch_size, self.seq_length]							,	self.vocab_size  )

    _UpperCamelCase       			=None
    if self.use_attention_mask:
      _UpperCamelCase       			=random_attention_mask([self.batch_size, self.seq_length]  )

    _UpperCamelCase       			=None
    if self.use_token_type_ids:
      _UpperCamelCase       			=ids_tensor([self.batch_size, self.seq_length]							,	self.type_vocab_size  )

    _UpperCamelCase       			=BertConfig(
        vocab_size=self.vocab_size							,	hidden_size=self.hidden_size							,	num_hidden_layers=self.num_hidden_layers							,	num_attention_heads=self.num_attention_heads							,	intermediate_size=self.intermediate_size							,	hidden_act=self.hidden_act							,	hidden_dropout_prob=self.hidden_dropout_prob							,	attention_probs_dropout_prob=self.attention_probs_dropout_prob							,	max_position_embeddings=self.max_position_embeddings							,	type_vocab_size=self.type_vocab_size							,	is_decoder=UpperCamelCase__							,	initializer_range=self.initializer_range							,	)

    return config, input_ids, token_type_ids, attention_mask


  def   UpperCamelCase__      (				self    :					int  )     ->						List[Any]:
    _UpperCamelCase       			=self.prepare_config_and_inputs()
    _UpperCamelCase			,     _UpperCamelCase			,     _UpperCamelCase			,     _UpperCamelCase       			=config_and_inputs
    _UpperCamelCase       			={'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
    return config, inputs_dict




  def   UpperCamelCase__      (				self    :					List[Any]  )     ->						List[Any]:
    _UpperCamelCase       			=self.prepare_config_and_inputs()
    _UpperCamelCase			,     _UpperCamelCase			,     _UpperCamelCase			,     _UpperCamelCase       			=config_and_inputs

    _UpperCamelCase       			=True
    _UpperCamelCase       			=floats_tensor([self.batch_size, self.seq_length, self.hidden_size]  )
    _UpperCamelCase       			=ids_tensor([self.batch_size, self.seq_length]							,	vocab_size=2  )

    return (
        config,
        input_ids,
        attention_mask,
        encoder_hidden_states,
        encoder_attention_mask,
    )







@require_flax
class 		UpperCAmelCase   (				lowercase_   ,     unittest.TestCase):


  """simple docstring"""







  lowerCAmelCase_					=				True

  lowerCAmelCase_					=				(
      (
          FlaxBertModel,
          FlaxBertForPreTraining,
          FlaxBertForMaskedLM,
          FlaxBertForMultipleChoice,
          FlaxBertForQuestionAnswering,
          FlaxBertForNextSentencePrediction,
          FlaxBertForSequenceClassification,
          FlaxBertForTokenClassification,
          FlaxBertForQuestionAnswering,
      )
      if is_flax_available()
      else ()
  )


  def   UpperCamelCase__      (				self    :					Optional[Any]  )     ->						Optional[Any]:
    _UpperCamelCase       			=FlaxBertModelTester(self  )




  @slow
  def   UpperCamelCase__      (				self    :					Optional[Any]  )     ->						int:
    # Only check this for base model, not necessary for all model classes.
    # This will also help speed-up tests.
    _UpperCamelCase       			=FlaxBertModel.from_pretrained('''bert-base-cased'''  )
    _UpperCamelCase       			=model(np.ones((1, 1)  )  )
    self.assertIsNotNone(UpperCamelCase__  )








'''simple docstring'''






def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  return 1 if digit in (0, 1) else (digit * factorial(digit - 1   ))


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  _UpperCamelCase       			=0
  _UpperCamelCase       			=number
  while duplicate > 0:
    _UpperCamelCase			,     _UpperCamelCase       			=divmod(__SCREAMING_SNAKE_CASE  ,      10   )
    fact_sum += factorial(__SCREAMING_SNAKE_CASE   )
  return fact_sum == number


if __name__ == "__main__":
      print('Program to check whether a number is a Krisnamurthy Number or not.')
      __lowerCamelCase						: Optional[Any]		=   int(input('Enter number: ').strip())
      print(
          F"""{number} is {'' if krishnamurthy(number) else 'not '}a Krishnamurthy Number."""
      )






