





def 	lowerCAmelCase_					(			__a						)	->						None:







  """simple docstring"""





  lowerCamelCase__: List[Any]         =generate_pascal_triangle(__a						)
  for row_idx in range(__a						):
    # Print left spaces
    for _ in range(num_rows - row_idx - 1						):
      print(end=" "						)
    # Print row values
    for col_idx in range(row_idx + 1						):
      if col_idx != row_idx:
        print(triangle[row_idx][col_idx]      ,       end=" "						)
      else:
        print(triangle[row_idx][col_idx]      ,       end=""						)
    print()





def 	lowerCAmelCase_					(			__a						)	->						list[list[int]]:







  """simple docstring"""





  if not isinstance(__a      ,       __a						):
    raise TypeError("The input value of 'num_rows' should be 'int'"						)

  if num_rows == 0:
    return []
  elif num_rows < 0:
    raise ValueError(
        "The input value of 'num_rows' should be greater than or equal to 0"						)

  lowerCamelCase__: list[list[int]]         =[]
  for current_row_idx in range(__a						):
    lowerCamelCase__: Any         =populate_current_row(__a      ,       __a						)
    triangle.append(__a						)
  return triangle





def 	lowerCAmelCase_					(			__a      ,       __a						)	->						list[int]:







  """simple docstring"""





  lowerCamelCase__: Dict         =[-1] * (current_row_idx + 1)
  # first and last elements of current row are equal to 1
  lowerCamelCase__    ,   lowerCamelCase__: Dict         =1, 1
  for current_col_idx in range(1      ,       __a						):
    calculate_current_element(
        __a      ,       __a      ,       __a      ,       __a						)
  return current_row





def 	lowerCAmelCase_					(			__a      ,       __a      ,       __a      ,       __a      ,       )	->						None:







  """simple docstring"""





  lowerCamelCase__: Dict         =triangle[current_row_idx - 1][current_col_idx - 1]
  lowerCamelCase__: List[Any]         =triangle[current_row_idx - 1][current_col_idx]
  lowerCamelCase__: int         =above_to_left_elt + above_to_right_elt





def 	lowerCAmelCase_					(			__a						)	->						list[list[int]]:







  """simple docstring"""





  if not isinstance(__a      ,       __a						):
    raise TypeError("The input value of 'num_rows' should be 'int'"						)

  if num_rows == 0:
    return []
  elif num_rows < 0:
    raise ValueError(
        "The input value of 'num_rows' should be greater than or equal to 0"						)

  lowerCamelCase__: list[list[int]]         =[[1]]

  for row_index in range(1      ,       __a						):
    lowerCamelCase__: str         =[0] + result[-1] + [0]
    lowerCamelCase__: List[str]         =row_index + 1
    # Calculate the number of distinct elements in a row
    lowerCamelCase__: str         =sum(divmod(__a      ,       2						)						)
    lowerCamelCase__: Union[str, Any]         =[
        temp_row[i - 1] + temp_row[i] for i in range(1      ,       distinct_elements + 1						)
    ]
    lowerCamelCase__: Optional[int]         =row_first_half[: (row_index + 1) // 2]
    row_second_half.reverse()
    lowerCamelCase__: Optional[int]         =row_first_half + row_second_half
    result.append(__a						)

  return result





def 	lowerCAmelCase_					(			)	->						None:







  """simple docstring"""





  from collections.abc import Callable
  from timeit import timeit

  def benchmark_a_function(__a      ,       __a						) -> None:
    lowerCamelCase__: Union[str, Any]         =F"""{func.__name__}({value})"""
    lowerCamelCase__: Any         =timeit(F"""__main__.{call}"""      ,       setup="import __main__"						)
    # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
    print(F"""{call:38} -- {timing:.4f} seconds"""						)

  for value in range(15						):  # (1, 7, 14):
    for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
      benchmark_a_function(__a      ,       __a						)
    print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()







from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase__					:  str      							=				logging.get_logger(__name__)

lowerCamelCase__					:  Tuple      							=				{
    'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/config.json',
    'funnel-transformer/small-base': 'https://huggingface.co/funnel-transformer/small-base/resolve/main/config.json',
    'funnel-transformer/medium': 'https://huggingface.co/funnel-transformer/medium/resolve/main/config.json',
    'funnel-transformer/medium-base': 'https://huggingface.co/funnel-transformer/medium-base/resolve/main/config.json',
    'funnel-transformer/intermediate': (
        'https://huggingface.co/funnel-transformer/intermediate/resolve/main/config.json'
    ),
    'funnel-transformer/intermediate-base': (
        'https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/config.json'
    ),
    'funnel-transformer/large': 'https://huggingface.co/funnel-transformer/large/resolve/main/config.json',
    'funnel-transformer/large-base': 'https://huggingface.co/funnel-transformer/large-base/resolve/main/config.json',
    'funnel-transformer/xlarge': 'https://huggingface.co/funnel-transformer/xlarge/resolve/main/config.json',
    'funnel-transformer/xlarge-base': 'https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/config.json',
}





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 lowercase_							       =       "funnel"
 lowercase_							       =       {
     "hidden_size": "d_model",
     "num_attention_heads": "n_head",
 }



 def __init__(				self    :						int							,							_lowerCAmelCase    :						Optional[int]=30_522							,							_lowerCAmelCase    :						List[str]=[4, 4, 4]							,							_lowerCAmelCase    :						Tuple=None							,							_lowerCAmelCase    :						Optional[int]=2							,							_lowerCAmelCase    :						int=768							,							_lowerCAmelCase    :						Optional[Any]=12							,							_lowerCAmelCase    :						Optional[Any]=64							,							_lowerCAmelCase    :						Optional[Any]=3_072							,							_lowerCAmelCase    :						List[str]="gelu_new"							,							_lowerCAmelCase    :						Any=0.1							,							_lowerCAmelCase    :						int=0.1							,							_lowerCAmelCase    :						Tuple=0.0							,							_lowerCAmelCase    :						List[Any]=0.1							,							_lowerCAmelCase    :						Dict=None							,							_lowerCAmelCase    :						str=1E-9							,							_lowerCAmelCase    :						Any="mean"							,							_lowerCAmelCase    :						Union[str, Any]="relative_shift"							,							_lowerCAmelCase    :						Optional[Any]=True							,							_lowerCAmelCase    :						Dict=True							,							_lowerCAmelCase    :						Tuple=True							,							**_lowerCAmelCase    :						Optional[Any]							,							):
       SCREAMING_SNAKE_CASE_      		=     vocab_size
       SCREAMING_SNAKE_CASE_      		=     block_sizes
       SCREAMING_SNAKE_CASE_      		=     [1] * len(_lowerCAmelCase		) if block_repeats is None else block_repeats
       assert len(_lowerCAmelCase		) == len(
           self.block_repeats		), "`block_sizes` and `block_repeats` should have the same length."
       SCREAMING_SNAKE_CASE_      		=     num_decoder_layers
       SCREAMING_SNAKE_CASE_      		=     d_model
       SCREAMING_SNAKE_CASE_      		=     n_head
       SCREAMING_SNAKE_CASE_      		=     d_head
       SCREAMING_SNAKE_CASE_      		=     d_inner
       SCREAMING_SNAKE_CASE_      		=     hidden_act
       SCREAMING_SNAKE_CASE_      		=     hidden_dropout
       SCREAMING_SNAKE_CASE_      		=     attention_dropout
       SCREAMING_SNAKE_CASE_      		=     activation_dropout
       SCREAMING_SNAKE_CASE_      		=     initializer_range
       SCREAMING_SNAKE_CASE_      		=     initializer_std
       SCREAMING_SNAKE_CASE_      		=     layer_norm_eps
       assert pooling_type in [
           "mean",
           "max",
       ], F"Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."
       SCREAMING_SNAKE_CASE_      		=     pooling_type
       assert attention_type in [
           "relative_shift",
           "factorized",
       ], F"Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."
       SCREAMING_SNAKE_CASE_      		=     attention_type
       SCREAMING_SNAKE_CASE_      		=     separate_cls
       SCREAMING_SNAKE_CASE_      		=     truncate_seq
       SCREAMING_SNAKE_CASE_      		=     pool_q_only

       super().__init__(**_lowerCAmelCase		)



 @property
 def  lowerCAmelCase_    (				self    :						Optional[int]		):
       return sum(self.block_sizes		)



 @num_hidden_layers.setter
 def  lowerCAmelCase_    (				self    :						int							,							_lowerCAmelCase    :						List[Any]		):
       raise NotImplementedError(
           'This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.'		)



 @property
 def  lowerCAmelCase_    (				self    :						List[Any]		):
       return len(self.block_sizes		)




 @num_blocks.setter
 def  lowerCAmelCase_    (				self    :						Dict							,							_lowerCAmelCase    :						Union[str, Any]		):
       raise NotImplementedError('This model does not support the setting of `num_blocks`. Please set `block_sizes`.'		)