

'''simple docstring'''



from ...configuration_utils import PretrainedConfig


UpperCAmelCase					:			Optional[Any]       =	{
    'google/tapas-base-finetuned-sqa': (
        'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-wtq': (
        'https://huggingface.co/google/tapas-base-finetuned-wtq/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-wikisql-supervised': (
        'https://huggingface.co/google/tapas-base-finetuned-wikisql-supervised/resolve/main/config.json'
    ),
    'google/tapas-base-finetuned-tabfact': (
        'https://huggingface.co/google/tapas-base-finetuned-tabfact/resolve/main/config.json'
    ),
}







class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""



 lowerCAmelCase__       = "tapas"
 def __init__(						self   :			int   ,				__SCREAMING_SNAKE_CASE   :			Tuple=30_522   ,				__SCREAMING_SNAKE_CASE   :			Tuple=768   ,				__SCREAMING_SNAKE_CASE   :			List[str]=12   ,				__SCREAMING_SNAKE_CASE   :			List[Any]=12   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=3_072   ,				__SCREAMING_SNAKE_CASE   :			Any="gelu"   ,				__SCREAMING_SNAKE_CASE   :			Dict=0.1   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=0.1   ,				__SCREAMING_SNAKE_CASE   :			Any=1_024   ,				__SCREAMING_SNAKE_CASE   :			int=[3, 256, 256, 2, 256, 256, 10]   ,				__SCREAMING_SNAKE_CASE   :			int=0.02   ,				__SCREAMING_SNAKE_CASE   :			List[str]=1E-12   ,				__SCREAMING_SNAKE_CASE   :			int=0   ,				__SCREAMING_SNAKE_CASE   :			List[Any]=10.0   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=0   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=1.0   ,				__SCREAMING_SNAKE_CASE   :			Dict=None   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=1.0   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=False   ,				__SCREAMING_SNAKE_CASE   :			Dict=None   ,				__SCREAMING_SNAKE_CASE   :			Dict=1.0   ,				__SCREAMING_SNAKE_CASE   :			int=1.0   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=False   ,				__SCREAMING_SNAKE_CASE   :			int=False   ,				__SCREAMING_SNAKE_CASE   :			Any="ratio"   ,				__SCREAMING_SNAKE_CASE   :			str=None   ,				__SCREAMING_SNAKE_CASE   :			int=None   ,				__SCREAMING_SNAKE_CASE   :			Optional[int]=64   ,				__SCREAMING_SNAKE_CASE   :			Tuple=32   ,				__SCREAMING_SNAKE_CASE   :			int=False   ,				__SCREAMING_SNAKE_CASE   :			List[Any]=True   ,				__SCREAMING_SNAKE_CASE   :			Tuple=False   ,				__SCREAMING_SNAKE_CASE   :			Optional[int]=False   ,				__SCREAMING_SNAKE_CASE   :			int=True   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=False   ,				__SCREAMING_SNAKE_CASE   :			Any=None   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=None   ,				**__SCREAMING_SNAKE_CASE   :			Any   ,				)    ->					List[str]:


      """simple docstring"""




      super().__init__(pad_token_id=__SCREAMING_SNAKE_CASE   ,				**__SCREAMING_SNAKE_CASE     )

      # BERT hyperparameters (with updated max_position_embeddings and type_vocab_sizes)
      __SCREAMING_SNAKE_CASE      = vocab_size
      __SCREAMING_SNAKE_CASE      = hidden_size
      __SCREAMING_SNAKE_CASE      = num_hidden_layers
      __SCREAMING_SNAKE_CASE      = num_attention_heads
      __SCREAMING_SNAKE_CASE      = hidden_act
      __SCREAMING_SNAKE_CASE      = intermediate_size
      __SCREAMING_SNAKE_CASE      = hidden_dropout_prob
      __SCREAMING_SNAKE_CASE      = attention_probs_dropout_prob
      __SCREAMING_SNAKE_CASE      = max_position_embeddings
      __SCREAMING_SNAKE_CASE      = type_vocab_sizes
      __SCREAMING_SNAKE_CASE      = initializer_range
      __SCREAMING_SNAKE_CASE      = layer_norm_eps

      # Fine-tuning task hyperparameters
      __SCREAMING_SNAKE_CASE      = positive_label_weight
      __SCREAMING_SNAKE_CASE      = num_aggregation_labels
      __SCREAMING_SNAKE_CASE      = aggregation_loss_weight
      __SCREAMING_SNAKE_CASE      = use_answer_as_supervision
      __SCREAMING_SNAKE_CASE      = answer_loss_importance
      __SCREAMING_SNAKE_CASE      = use_normalized_answer_loss
      __SCREAMING_SNAKE_CASE      = huber_loss_delta
      __SCREAMING_SNAKE_CASE      = temperature
      __SCREAMING_SNAKE_CASE      = aggregation_temperature
      __SCREAMING_SNAKE_CASE      = use_gumbel_for_cells
      __SCREAMING_SNAKE_CASE      = use_gumbel_for_aggregation
      __SCREAMING_SNAKE_CASE      = average_approximation_function
      __SCREAMING_SNAKE_CASE      = cell_selection_preference
      __SCREAMING_SNAKE_CASE      = answer_loss_cutoff
      __SCREAMING_SNAKE_CASE      = max_num_rows
      __SCREAMING_SNAKE_CASE      = max_num_columns
      __SCREAMING_SNAKE_CASE      = average_logits_per_cell
      __SCREAMING_SNAKE_CASE      = select_one_column
      __SCREAMING_SNAKE_CASE      = allow_empty_column_selection
      __SCREAMING_SNAKE_CASE      = init_cell_selection_weights_to_zero
      __SCREAMING_SNAKE_CASE      = reset_position_index_per_cell
      __SCREAMING_SNAKE_CASE      = disable_per_token_loss

      # Aggregation hyperparameters
      __SCREAMING_SNAKE_CASE      = aggregation_labels
      __SCREAMING_SNAKE_CASE      = no_aggregation_label_index

      if isinstance(self.aggregation_labels   ,				__SCREAMING_SNAKE_CASE     ):
           __SCREAMING_SNAKE_CASE      = {int(__SCREAMING_SNAKE_CASE     ): v for k, v in aggregation_labels.items()}









'''simple docstring'''



UpperCAmelCase					:			Tuple       =	range(2, 2_0 + 1)
UpperCAmelCase					:			int       =	[1_0**k for k in range(ks[-1] + 1)]
UpperCAmelCase					:			dict[int, dict[int, list[list[int]]]]       =	{}







def   a__			(    a__ ,       a__ ,       a__ ,       a__		):




     """simple docstring"""


     __SCREAMING_SNAKE_CASE      = sum(a_i[j] for j in range(a__ ,       len(a__		)		)		)
     __SCREAMING_SNAKE_CASE      = sum(a_i[j] * base[j] for j in range(min(len(a__		) ,       a__		)		)		)

     __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = 0, 0
     __SCREAMING_SNAKE_CASE      = n - i

     __SCREAMING_SNAKE_CASE      = memo.get(a__		)

     if sub_memo is not None:
          __SCREAMING_SNAKE_CASE      = sub_memo.get(a__		)

          if jumps is not None and len(a__		) > 0:
               # find and make the largest jump without going over
               __SCREAMING_SNAKE_CASE      = -1
               for _k in range(len(a__		) - 1 ,       -1 ,       -1		):
                    if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
                         __SCREAMING_SNAKE_CASE      = _k
                         break

               if max_jump >= 0:
                    __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = jumps[max_jump]
                    # since the difference between jumps is cached, add c
                    __SCREAMING_SNAKE_CASE      = diff + c
                    for j in range(min(a__ ,       len(a__		)		)		):
                         __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = divmod(a__ ,       10		)
                    if new_c > 0:
                         add(a__ ,       a__ ,       a__		)

          else:
               __SCREAMING_SNAKE_CASE      = []
     else:
          __SCREAMING_SNAKE_CASE      = {c: []}
          __SCREAMING_SNAKE_CASE      = sub_memo

     if dn >= max_dn or c + diff >= base[k]:
          return diff, dn

     if k > ks[0]:
          while True:
               # keep doing smaller jumps
               __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = next_term(a__ ,       k - 1 ,       i + dn ,       a__		)
               diff += _diff
               dn += terms_jumped

               if dn >= max_dn or c + diff >= base[k]:
                    break
     else:
          # would be too small a jump, just compute sequential terms instead
          __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = compute(a__ ,       a__ ,       i + dn ,       a__		)
          diff += _diff
          dn += terms_jumped

     __SCREAMING_SNAKE_CASE      = sub_memo[c]

     # keep jumps sorted by # of terms skipped
     __SCREAMING_SNAKE_CASE      = 0
     while j < len(a__		):
          if jumps[j][1] > dn:
               break
          j += 1

     # cache the jump for this value digitsum(b) and c
     sub_memo[c].insert(a__ ,       (diff, dn, k)		)
     return (diff, dn)







def   a__			(    a__ ,       a__ ,       a__ ,       a__		):




     """simple docstring"""


     if i >= n:
          return 0, i
     if k > len(a__		):
          a_i.extend([0 for _ in range(k - len(a__		)		)]		)

     # note: a_i -> b * 10^k + c
     # ds_b -> digitsum(b)
     # ds_c -> digitsum(c)
     __SCREAMING_SNAKE_CASE      = i
     __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = 0, 0, 0
     for j in range(len(a__		)		):
          if j >= k:
               ds_b += a_i[j]
          else:
               ds_c += a_i[j]

     while i < n:
          i += 1
          __SCREAMING_SNAKE_CASE      = ds_c + ds_b
          diff += addend
          __SCREAMING_SNAKE_CASE      = 0
          for j in range(a__		):
               __SCREAMING_SNAKE_CASE      = a_i[j] + addend
               __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = divmod(a__ ,       10		)

               ds_c += a_i[j]

          if addend > 0:
               break

     if addend > 0:
          add(a__ ,       a__ ,       a__		)
     return diff, i - start_i







def   a__			(    a__ ,       a__ ,       a__		):




     """simple docstring"""


     for j in range(a__ ,       len(a__		)		):
          __SCREAMING_SNAKE_CASE      = digits[j] + addend
          if s >= 10:
               __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = divmod(a__ ,       10		)
               __SCREAMING_SNAKE_CASE      = addend // 10 + quotient
          else:
               __SCREAMING_SNAKE_CASE      = s
               __SCREAMING_SNAKE_CASE      = addend // 10

          if addend == 0:
               break

     while addend > 0:
          __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = divmod(a__ ,       10		)
          digits.append(a__		)







def   a__			(    a__ = 10**15		):




     """simple docstring"""


     __SCREAMING_SNAKE_CASE      = [1]
     __SCREAMING_SNAKE_CASE      = 1
     __SCREAMING_SNAKE_CASE      = 0
     while True:
          __SCREAMING_SNAKE_CASE  ,     __SCREAMING_SNAKE_CASE      = next_term(a__ ,       20 ,       i + dn ,       a__		)
          dn += terms_jumped
          if dn == n - i:
               break

     __SCREAMING_SNAKE_CASE      = 0
     for j in range(len(a__		)		):
          a_n += digits[j] * 10**j
     return a_n


if __name__ == "__main__":
  print(f"""{solution() = }""")






