def 							UpperCamelCase		(			__lowercase		:					Optional[Any]		,__lowercase		:					List[Any]		,__lowercase		:					Tuple      ):
		'''simple docstring'''




		if n == 0:
				return 1

		elif n % 2 == 1:
				return (binary_exponentiation(__lowercase		,n - 1		,__lowercase      ) * a) % mod

		else:
				A_						:							str      = binary_exponentiation(__lowercase		,n / 2		,__lowercase      )
				return (b * b) % mod


# a prime number
_UpperCAmelCase          =						701

_UpperCAmelCase          =						1000000000
_UpperCAmelCase          =						10

# using binary exponentiation function, O(log(p)):
print((a / b) % p == (a * binary_exponentiation(b, p - 2, p)) % p)


print((a / b) % p == (a * b ** (p - 2)) % p)







import torch
import torch.nn as nn
from transformers.modeling_utils import ModuleUtilsMixin
from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm

from ...configuration_utils import ConfigMixin, register_to_config
from ...models import ModelMixin





class UpperCAmelCase		(   __A   ,			__A   ,			__A    ):


				'''simple docstring'''






				@register_to_config
				def __init__(		self						,      lowercase						,      lowercase						,      lowercase						,      lowercase						,      lowercase						,      lowercase						,      lowercase						,      lowercase						,      lowercase						,      lowercase = False						,      ):



						"""simple docstring"""





						super().__init__()

						A_						:							Optional[int]      = nn.Embedding(lowercase						,      lowercase   )

						A_						:							Any      = nn.Embedding(lowercase						,      lowercase   )
						A_						:							int      = False

						A_						:							Tuple      = nn.Dropout(p=lowercase   )

						A_						:							List[Any]      = TaConfig(
						    vocab_size=lowercase						,      d_model=lowercase						,      num_heads=lowercase						,      d_kv=lowercase						,      d_ff=lowercase						,      dropout_rate=lowercase						,      feed_forward_proj=lowercase						,      is_decoder=lowercase						,      is_encoder_decoder=lowercase						,      )

						A_						:							List[str]      = nn.ModuleList()
						for lyr_num in range(lowercase   ):
								A_						:							Dict      = TaBlock(lowercase   )
								self.encoders.append(lowercase   )

						A_						:							Any      = TaLayerNorm(lowercase   )
						A_						:							Optional[int]      = nn.Dropout(p=lowercase   )







				def     lowerCAmelCase_  (		self						,      lowercase						,      lowercase   ):



						"""simple docstring"""





						A_						:							Any      = self.token_embedder(lowercase   )

						A_						:							List[Any]      = encoder_input_tokens.shape[1]
						A_						:							int      = torch.arange(lowercase						,      device=encoder_input_tokens.device   )
						x += self.position_encoding(lowercase   )

						A_						:							Dict      = self.dropout_pre(lowercase   )

						# inverted the attention mask
						A_						:							List[Any]      = encoder_input_tokens.size()
						A_						:							Dict      = self.get_extended_attention_mask(lowercase						,      lowercase   )

						for lyr in self.encoders:
								A_						:							List[str]      = lyr(lowercase						,      lowercase   )[0]
						A_						:							Optional[int]      = self.layer_norm(lowercase   )

						return self.dropout_post(lowercase   ), encoder_inputs_mask






