



import torch
from torch import nn
from torch.nn import CrossEntropyLoss, MSELoss

from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
from transformers.models.bert.modeling_bert import (
    BERT_INPUTS_DOCSTRING,
    BERT_START_DOCSTRING,
    BertEmbeddings,
    BertLayer,
    BertPooler,
    BertPreTrainedModel,
)

def 	_lowerCAmelCase (    A__						):
      lowercase__  =	torch.exp(A__						)
      lowercase__  =	torch.sum(A__    ,	dim=1						)  # sum of exp(x_i)
      lowercase__  =	torch.sum(x * exp_x    ,	dim=1						)  # sum of x_i * exp(x_i)
      return torch.log(A__						) - B / A



class    UpperCAmelCase__(				nn.Module						):

   '''simple docstring'''




   def __init__(    self	:      Union[str, Any]      ,					lowerCAmelCase	:      Optional[int])						->					Optional[Any]:




         """simple docstring"""

         super().__init__()
         lowercase__  =	config.output_attentions
         lowercase__  =	config.output_hidden_states
         lowercase__  =	nn.ModuleList([BertLayer(lowerCAmelCase) for _ in range(config.num_hidden_layers)])
         lowercase__  =	nn.ModuleList([BertHighway(lowerCAmelCase) for _ in range(config.num_hidden_layers)])

         lowercase__  =	[-1 for _ in range(config.num_hidden_layers)]


   def       UpperCAmelCase		(    self	:      Tuple      ,					lowerCAmelCase	:      Optional[int])						->					Dict:




         """simple docstring"""

         if (type(lowerCAmelCase) is float) or (type(lowerCAmelCase) is int):
               for i in range(len(self.early_exit_entropy)):
                     lowercase__  =	x
         else:
               lowercase__  =	x


   def       UpperCAmelCase		(    self	:      Union[str, Any]      ,					lowerCAmelCase	:      Any)						->					List[str]:




         """simple docstring"""

         lowercase__  =	pooler.state_dict()
         for highway in self.highway:
               for name, param in highway.pooler.state_dict().items():
                     param.copy_(loaded_model[name])



   def       UpperCAmelCase		(    self	:      Optional[Any]      ,					lowerCAmelCase	:      Tuple      ,					lowerCAmelCase	:      Union[str, Any]=None      ,					lowerCAmelCase	:      Optional[Any]=None      ,					lowerCAmelCase	:      Optional[Any]=None      ,					lowerCAmelCase	:      Union[str, Any]=None      ,					)						->					str:




         """simple docstring"""

         lowercase__  =	()
         lowercase__  =	()
         lowercase__  =	()
         for i, layer_module in enumerate(self.layer):
               if self.output_hidden_states:
                     lowercase__  =	all_hidden_states + (hidden_states,)

               lowercase__  =	layer_module(
                   lowerCAmelCase      ,					lowerCAmelCase      ,					head_mask[i]      ,					lowerCAmelCase      ,					lowerCAmelCase)
               lowercase__  =	layer_outputs[0]

               if self.output_attentions:
                     lowercase__  =	all_attentions + (layer_outputs[1],)

               lowercase__  =	(hidden_states,)
               if self.output_hidden_states:
                     lowercase__  =	current_outputs + (all_hidden_states,)
               if self.output_attentions:
                     lowercase__  =	current_outputs + (all_attentions,)

               lowercase__  =	self.highway[i](lowerCAmelCase)
               # logits, pooled_output

               if not self.training:
                     lowercase__  =	highway_exit[0]
                     lowercase__  =	entropy(lowerCAmelCase)
                     lowercase__  =	highway_exit + (highway_entropy,)  # logits, hidden_states(?), entropy
                     lowercase__  =	all_highway_exits + (highway_exit,)

                     if highway_entropy < self.early_exit_entropy[i]:
                           lowercase__  =	(highway_logits,) + current_outputs[1:] + (all_highway_exits,)
                           raise HighwayException(lowerCAmelCase      ,					i + 1)
               else:
                     lowercase__  =	all_highway_exits + (highway_exit,)

        # Add last layer
         if self.output_hidden_states:
               lowercase__  =	all_hidden_states + (hidden_states,)

         lowercase__  =	(hidden_states,)
         if self.output_hidden_states:
               lowercase__  =	outputs + (all_hidden_states,)
         if self.output_attentions:
               lowercase__  =	outputs + (all_attentions,)

         lowercase__  =	outputs + (all_highway_exits,)
         return outputs  # last-layer hidden state, (all hidden states), (all attentions), all highway exits



@add_start_docstrings(
    "The Bert Model transformer with early exiting (DeeBERT). "  ,				lowerCamelCase  ,				)
class    UpperCAmelCase__(				lowerCamelCase						):

   '''simple docstring'''




   def __init__(    self	:      List[str]      ,					lowerCAmelCase	:      Optional[Any])						->					Union[str, Any]:




         """simple docstring"""

         super().__init__(lowerCAmelCase)
         lowercase__  =	config

         lowercase__  =	BertEmbeddings(lowerCAmelCase)
         lowercase__  =	DeeBertEncoder(lowerCAmelCase)
         lowercase__  =	BertPooler(lowerCAmelCase)

         self.init_weights()


   def       UpperCAmelCase		(    self	:      Optional[int])						->					Optional[int]:




         """simple docstring"""

         self.encoder.init_highway_pooler(self.pooler)


   def       UpperCAmelCase		(    self	:      Tuple)						->					Optional[Any]:




         """simple docstring"""

         return self.embeddings.word_embeddings


   def       UpperCAmelCase		(    self	:      Dict      ,					lowerCAmelCase	:      List[Any])						->					List[Any]:




         """simple docstring"""

         lowercase__  =	value


   def       UpperCAmelCase		(    self	:      List[Any]      ,					lowerCAmelCase	:      int)						->					Union[str, Any]:




         """simple docstring"""

         for layer, heads in heads_to_prune.items():
               self.encoder.layer[layer].attention.prune_heads(lowerCAmelCase)



   @add_start_docstrings_to_model_forward(lowerCAmelCase)
   def       UpperCAmelCase		(    self	:      Optional[Any]      ,					lowerCAmelCase	:      str=None      ,					lowerCAmelCase	:      Dict=None      ,					lowerCAmelCase	:      Dict=None      ,					lowerCAmelCase	:      Optional[int]=None      ,					lowerCAmelCase	:      List[str]=None      ,					lowerCAmelCase	:      Dict=None      ,					lowerCAmelCase	:      Optional[int]=None      ,					lowerCAmelCase	:      Optional[int]=None      ,					)						->					List[str]:




         """simple docstring"""

         if input_ids is not None and inputs_embeds is not None:
               raise ValueError('You cannot specify both input_ids and inputs_embeds at the same time')
         elif input_ids is not None:
               lowercase__  =	input_ids.size()
         elif inputs_embeds is not None:
               lowercase__  =	inputs_embeds.size()[:-1]
         else:
               raise ValueError('You have to specify either input_ids or inputs_embeds')

         lowercase__  =	input_ids.device if input_ids is not None else inputs_embeds.device

         if attention_mask is None:
               lowercase__  =	torch.ones(lowerCAmelCase      ,					device=lowerCAmelCase)
         if encoder_attention_mask is None:
               lowercase__  =	torch.ones(lowerCAmelCase      ,					device=lowerCAmelCase)
         if token_type_ids is None:
               lowercase__  =	torch.zeros(lowerCAmelCase      ,					dtype=torch.long      ,					device=lowerCAmelCase)

         # We can provide a self-attention mask of dimensions [batch_size, from_seq_length, to_seq_length]
         # ourselves in which case we just need to make it broadcastable to all heads.
         lowercase__  =	self.get_extended_attention_mask(lowerCAmelCase      ,					lowerCAmelCase      ,					lowerCAmelCase)

         # If a 2D ou 3D attention mask is provided for the cross-attention
         # we need to make broadcastable to [batch_size, num_heads, seq_length, seq_length]
         if encoder_attention_mask.dim() == 3:
               lowercase__  =	encoder_attention_mask[:, None, :, :]
         if encoder_attention_mask.dim() == 2:
               lowercase__  =	encoder_attention_mask[:, None, None, :]

         lowercase__  =	encoder_extended_attention_mask.to(
             dtype=next(self.parameters()).dtype)  # fp16 compatibility
         lowercase__  =	(1.0 - encoder_extended_attention_mask) * -1_00_00.0

         # Prepare head mask if needed
         # 1.0 in head_mask indicate we keep the head
         # attention_probs has shape bsz x n_heads x N x N
         # input head_mask has shape [num_heads] or [num_hidden_layers x num_heads]
         # and head_mask is converted to shape [num_hidden_layers x batch x num_heads x seq_length x seq_length]
         lowercase__  =	self.get_head_mask(lowerCAmelCase      ,					self.config.num_hidden_layers)

         lowercase__  =	self.embeddings(
             input_ids=lowerCAmelCase      ,					position_ids=lowerCAmelCase      ,					token_type_ids=lowerCAmelCase      ,					inputs_embeds=lowerCAmelCase)
         lowercase__  =	self.encoder(
             lowerCAmelCase      ,					attention_mask=lowerCAmelCase      ,					head_mask=lowerCAmelCase      ,					encoder_hidden_states=lowerCAmelCase      ,					encoder_attention_mask=lowerCAmelCase      ,					)
         lowercase__  =	encoder_outputs[0]
         lowercase__  =	self.pooler(lowerCAmelCase)

         lowercase__  =	(
             sequence_output,
             pooled_output,
         ) + encoder_outputs[
             1:
         ]  # add hidden_states and attentions if they are here
         return outputs  # sequence_output, pooled_output, (hidden_states), (attentions), highway exits



class    UpperCAmelCase__(				lowerCamelCase						):

   '''simple docstring'''




   def __init__(    self	:      Optional[Any]      ,					lowerCAmelCase	:      Optional[Any]      ,					lowerCAmelCase	:      Any)						->					Optional[int]:




         """simple docstring"""

         lowercase__  =	message
         lowercase__  =	exit_layer  # start from 1!



class    UpperCAmelCase__(				nn.Module						):

   '''simple docstring'''




   def __init__(    self	:      int      ,					lowerCAmelCase	:      List[str])						->					Optional[Any]:




         """simple docstring"""

         super().__init__()
         lowercase__  =	BertPooler(lowerCAmelCase)
         lowercase__  =	nn.Dropout(config.hidden_dropout_prob)
         lowercase__  =	nn.Linear(config.hidden_size      ,					config.num_labels)



   def       UpperCAmelCase		(    self	:      int      ,					lowerCAmelCase	:      str)						->					int:




         """simple docstring"""

         lowercase__  =	encoder_outputs[0]
         lowercase__  =	self.pooler(lowerCAmelCase)
         # "return" pooler_output

         # BertModel
         lowercase__  =	(pooler_input, pooler_output) + encoder_outputs[1:]
         # "return" bmodel_output

         # Dropout and classification
         lowercase__  =	bmodel_output[1]

         lowercase__  =	self.dropout(lowerCAmelCase)
         lowercase__  =	self.classifier(lowerCAmelCase)

         return logits, pooled_output



@add_start_docstrings(
    "Bert Model (with early exiting - DeeBERT) with a classifier on top,\n    also takes care of multi-layer training. "  ,				lowerCamelCase  ,				)
class    UpperCAmelCase__(				lowerCamelCase						):

   '''simple docstring'''




   def __init__(    self	:      Dict      ,					lowerCAmelCase	:      Tuple)						->					List[str]:




         """simple docstring"""

         super().__init__(lowerCAmelCase)
         lowercase__  =	config.num_labels
         lowercase__  =	config.num_hidden_layers

         lowercase__  =	DeeBertModel(lowerCAmelCase)
         lowercase__  =	nn.Dropout(config.hidden_dropout_prob)
         lowercase__  =	nn.Linear(config.hidden_size      ,					self.config.num_labels)

         self.init_weights()



   @add_start_docstrings_to_model_forward(lowerCAmelCase)
   def       UpperCAmelCase		(    self	:      List[Any]      ,					lowerCAmelCase	:      Optional[Any]=None      ,					lowerCAmelCase	:      Optional[Any]=None      ,					lowerCAmelCase	:      List[Any]=None      ,					lowerCAmelCase	:      Dict=None      ,					lowerCAmelCase	:      List[str]=None      ,					lowerCAmelCase	:      List[Any]=None      ,					lowerCAmelCase	:      List[Any]=None      ,					lowerCAmelCase	:      Union[str, Any]=-1      ,					lowerCAmelCase	:      List[str]=False      ,					)						->					int:




         """simple docstring"""

         lowercase__  =	self.num_layers
         try:
               lowercase__  =	self.bert(
                   lowerCAmelCase      ,					attention_mask=lowerCAmelCase      ,					token_type_ids=lowerCAmelCase      ,					position_ids=lowerCAmelCase      ,					head_mask=lowerCAmelCase      ,					inputs_embeds=lowerCAmelCase      ,					)
               # sequence_output, pooled_output, (hidden_states), (attentions), highway exits

               lowercase__  =	outputs[1]

               lowercase__  =	self.dropout(lowerCAmelCase)
               lowercase__  =	self.classifier(lowerCAmelCase)
               lowercase__  =	(logits,) + outputs[2:]  # add hidden states and attention if they are here
         except HighwayException as e:
               lowercase__  =	e.message
               lowercase__  =	e.exit_layer
               lowercase__  =	outputs[0]

         if not self.training:
               lowercase__  =	entropy(lowerCAmelCase)
               lowercase__  =	[]
               lowercase__  =	[]
         if labels is not None:
               if self.num_labels == 1:
                     #  We are doing regression
                     lowercase__  =	MSELoss()
                     lowercase__  =	loss_fct(logits.view(-1)      ,					labels.view(-1))
               else:
                     lowercase__  =	CrossEntropyLoss()
                     lowercase__  =	loss_fct(logits.view(-1      ,					self.num_labels)      ,					labels.view(-1))

               # work with highway exits
               lowercase__  =	[]
               for highway_exit in outputs[-1]:
                     lowercase__  =	highway_exit[0]
                     if not self.training:
                           highway_logits_all.append(lowerCAmelCase)
                           highway_entropy.append(highway_exit[2])
                     if self.num_labels == 1:
                           #  We are doing regression
                           lowercase__  =	MSELoss()
                           lowercase__  =	loss_fct(highway_logits.view(-1)      ,					labels.view(-1))
                     else:
                           lowercase__  =	CrossEntropyLoss()
                           lowercase__  =	loss_fct(highway_logits.view(-1      ,					self.num_labels)      ,					labels.view(-1))
                     highway_losses.append(lowerCAmelCase)

               if train_highway:
                     lowercase__  =	(sum(highway_losses[:-1]),) + outputs
                     # exclude the final highway, of course
               else:
                     lowercase__  =	(loss,) + outputs
         if not self.training:
               lowercase__  =	outputs + ((original_entropy, highway_entropy), exit_layer)
               if output_layer >= 0:
                     lowercase__  =	(
                         (outputs[0],) + (highway_logits_all[output_layer],) + outputs[2:]
                     )  # use the highway of the last layer

         return outputs  # (loss), logits, (hidden_states), (attentions), (highway_exits)





from math import sqrt

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (
          number >= 0
      ), "'number' must been an int and positive"

      lowercase__  =	True

      # 0 and 1 are none primes.
      if number <= 1:
            lowercase__  =	False

      for divisor in range(2    ,	int(round(sqrt(A__						)						)						) + 1						):
            # if 'number' divisible by 'divisor' then sets 'status'
            # of false and break up the loop.
            if number % divisor == 0:
                  lowercase__  =	False
                  break

    # precondition
      assert isinstance(A__    ,	A__						), "'status' must been from type bool"

      return status

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (n > 2), "'N' must been an int and > 2"

      # beginList: contains all natural numbers from 2 up to N
      lowercase__  =	list(range(2    ,	n + 1						)						)

      lowercase__  =	[]  # this list will be returns.

      # actual sieve of erathostenes
      for i in range(len(A__						)						):
            for j in range(i + 1    ,	len(A__						)						):
                  if (begin_list[i] != 0) and (begin_list[j] % begin_list[i] == 0):
                        lowercase__  =	0

    # filters actual prime numbers.
      lowercase__  =	[x for x in begin_list if x != 0]

      # precondition
      assert isinstance(A__    ,	A__						), "'ans' must been from type list"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (n > 2), "'N' must been an int and > 2"

      lowercase__  =	[]

      # iterates over all numbers between 2 up to N+1
      # if a number is prime then appends to list 'ans'
      for number in range(2    ,	n + 1						):
            if is_prime(A__						):
                  ans.append(A__						)

    # precondition
      assert isinstance(A__    ,	A__						), "'ans' must been from type list"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and number >= 0, "'number' must been an int and >= 0"

      lowercase__  =	[]  # this list will be returns of the function.

      # potential prime number factors.

      lowercase__  =	2

      lowercase__  =	number

      if number == 0 or number == 1:
            ans.append(A__						)

      # if 'number' not prime then builds the prime factorization of 'number'
      elif not is_prime(A__						):
            while quotient != 1:
                  if is_prime(A__						) and (quotient % factor == 0):
                        ans.append(A__						)
                        quotient /= factor
                  else:
                        factor += 1

      else:
            ans.append(A__						)

      # precondition
      assert isinstance(A__    ,	A__						), "'ans' must been from type list"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (
          number >= 0
      ), "'number' bust been an int and >= 0"

      lowercase__  =	0

      # prime factorization of 'number'
      lowercase__  =	prime_factorization(A__						)

      lowercase__  =	max(A__						)

      # precondition
      assert isinstance(A__    ,	A__						), "'ans' must been from type int"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (
          number >= 0
      ), "'number' bust been an int and >= 0"

      lowercase__  =	0

      # prime factorization of 'number'
      lowercase__  =	prime_factorization(A__						)

      lowercase__  =	min(A__						)

      # precondition
      assert isinstance(A__    ,	A__						), "'ans' must been from type int"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						), "'number' must been an int"
      assert isinstance(number % 2 == 0    ,	A__						), "compare bust been from type bool"

      return number % 2 == 0

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						), "'number' must been an int"
      assert isinstance(number % 2 != 0    ,	A__						), "compare bust been from type bool"

      return number % 2 != 0

def 	_lowerCAmelCase (    A__						):
      assert (
          isinstance(A__    ,	A__						) and (number > 2) and is_even(A__						)
      ), "'number' must been an int, even and > 2"

      lowercase__  =	[]  # this list will returned

      # creates a list of prime numbers between 2 up to 'number'
      lowercase__  =	get_prime_numbers(A__						)
      lowercase__  =	len(A__						)

      # run variable for while-loops.
      lowercase__  =	0
      lowercase__  =	None

      # exit variable. for break up the loops
      lowercase__  =	True

      while i < len_pn and loop:
            lowercase__  =	i + 1

            while j < len_pn and loop:
                  if prime_numbers[i] + prime_numbers[j] == number:
                        lowercase__  =	False
                        ans.append(prime_numbers[i]						)
                        ans.append(prime_numbers[j]						)

                  j += 1

            i += 1

      # precondition
      assert (
          isinstance(A__    ,	A__						)
          and (len(A__						) == 2)
          and (ans[0] + ans[1] == number)
          and is_prime(ans[0]						)
          and is_prime(ans[1]						)
      ), "'ans' must contains two primes. And sum of elements must been eq 'number'"

      return ans

def 	_lowerCAmelCase (    A__    ,	A__						):
      assert (
          isinstance(A__    ,	A__						)
          and isinstance(A__    ,	A__						)
          and (numbera >= 0)
          and (numbera >= 0)
      ), "'number1' and 'number2' must been positive integer."

      lowercase__  =	0

      while numbera != 0:
            lowercase__  =	numbera % numbera
            lowercase__  =	numbera
            lowercase__  =	rest

      # precondition
      assert isinstance(A__    ,	A__						) and (
          numbera >= 0
      ), "'number' must been from type int and positive"

      return numbera

def 	_lowerCAmelCase (    A__    ,	A__						):
      assert (
          isinstance(A__    ,	A__						)
          and isinstance(A__    ,	A__						)
          and (numbera >= 1)
          and (numbera >= 1)
      ), "'number1' and 'number2' must been positive integer."

      lowercase__  =	1  # actual answer that will be return.

      # for kgV (x,1)
      if numbera > 1 and numbera > 1:
            # builds the prime factorization of 'number1' and 'number2'
            lowercase__  =	prime_factorization(A__						)
            lowercase__  =	prime_factorization(A__						)

      elif numbera == 1 or numbera == 1:
            lowercase__  =	[]
            lowercase__  =	[]
            lowercase__  =	max(A__    ,	A__						)

      lowercase__  =	0
      lowercase__  =	0

      lowercase__  =	[]  # captured numbers int both 'primeFac1' and 'primeFac2'

      # iterates through primeFac1
      for n in prime_fac_a:
            if n not in done:
                  if n in prime_fac_a:
                        lowercase__  =	prime_fac_a.count(A__						)
                        lowercase__  =	prime_fac_a.count(A__						)

                        for _ in range(max(A__    ,	A__						)						):
                              ans *= n

                  else:
                        lowercase__  =	prime_fac_a.count(A__						)

                        for _ in range(A__						):
                              ans *= n

                  done.append(A__						)

    # iterates through primeFac2
      for n in prime_fac_a:
            if n not in done:
                  lowercase__  =	prime_fac_a.count(A__						)

                  for _ in range(A__						):
                        ans *= n

                  done.append(A__						)

    # precondition
      assert isinstance(A__    ,	A__						) and (
          ans >= 0
      ), "'ans' must been from type int and positive"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (n >= 0), "'number' must been a positive int"

      lowercase__  =	0
      lowercase__  =	2  # this variable holds the answer

      while index < n:
            index += 1

            ans += 1  # counts to the next number

            # if ans not prime then
            # runs to the next prime number.
            while not is_prime(A__						):
                  ans += 1

    # precondition
      assert isinstance(A__    ,	A__						) and is_prime(
          A__						), "'ans' must been a prime number and from type int"

      return ans

def 	_lowerCAmelCase (    A__    ,	A__						):
      assert (
          is_prime(A__						) and is_prime(A__						) and (p_number_a < p_number_a)
      ), "The arguments must been prime numbers and 'pNumber1' < 'pNumber2'"

      lowercase__  =	p_number_a + 1  # jump to the next number

      lowercase__  =	[]  # this list will be returns.

      # if number is not prime then
      # fetch the next prime number.
      while not is_prime(A__						):
            number += 1

      while number < p_number_a:
            ans.append(A__						)

            number += 1

            # fetch the next prime number.
            while not is_prime(A__						):
                  number += 1

    # precondition
      assert (
          isinstance(A__    ,	A__						)
          and ans[0] != p_number_a
          and ans[len(A__						) - 1] != p_number_a
      ), "'ans' must been a list without the arguments"

      # 'ans' contains not 'pNumber1' and 'pNumber2' !
      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (n >= 1), "'n' must been int and >= 1"

      lowercase__  =	[]  # will be returned.

      for divisor in range(1    ,	n + 1						):
            if n % divisor == 0:
                  ans.append(A__						)

    # precondition
      assert ans[0] == 1 and ans[len(A__						) - 1] == n, "Error in function getDivisiors(...)"

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (
          number > 1
      ), "'number' must been an int and >= 1"

      lowercase__  =	get_divisors(A__						)

      # precondition
      assert (
          isinstance(A__    ,	A__						)
          and (divisors[0] == 1)
          and (divisors[len(A__						) - 1] == number)
      ), "Error in help-function getDivisiors(...)"

      # summed all divisors up to 'number' (exclusive), hence [:-1]
      return sum(divisors[:-1]						) == number

def 	_lowerCAmelCase (    A__    ,	A__						):
      assert (
          isinstance(A__    ,	A__						)
          and isinstance(A__    ,	A__						)
          and (denominator != 0)
      ), "The arguments must been from type int and 'denominator' != 0"

      # build the greatest common divisor of numerator and denominator.
      lowercase__  =	gcd(abs(A__						)    ,	abs(A__						)						)

      # precondition
      assert (
          isinstance(A__    ,	A__						)
          and (numerator % gcd_of_fraction == 0)
          and (denominator % gcd_of_fraction == 0)
      ), "Error in function gcd(...,...)"

      return (numerator // gcd_of_fraction, denominator // gcd_of_fraction)

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (n >= 0), "'n' must been a int and >= 0"

      lowercase__  =	1  # this will be return.

      for factor in range(1    ,	n + 1						):
            ans *= factor

      return ans

def 	_lowerCAmelCase (    A__						):
      assert isinstance(A__    ,	A__						) and (n >= 0), "'n' must been an int and >= 0"

      lowercase__  =	0
      lowercase__  =	1
      lowercase__  =	1  # this will be return

      for _ in range(n - 1						):
            lowercase__  =	ans
            ans += fiba
            lowercase__  =	tmp

      return ans
