




def 						lowerCAmelCase		(		_lowerCAmelCase							:   int	):




 """simple docstring"""







 UpperCAmelCase__							 =						generate_pascal_triangle(_lowerCAmelCase	)
 for row_idx in range(_lowerCAmelCase	):
  # 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		(		_lowerCAmelCase							:   int	):




 """simple docstring"""







 if not isinstance(_lowerCAmelCase						,							_lowerCAmelCase	):
  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"	)

 UpperCAmelCase__							 =						[]
 for current_row_idx in range(_lowerCAmelCase	):
  UpperCAmelCase__							 =						populate_current_row(_lowerCAmelCase						,							_lowerCAmelCase	)
  triangle.append(_lowerCAmelCase	)
 return triangle



def 						lowerCAmelCase		(		_lowerCAmelCase							:   list[list[int]]						,							_lowerCAmelCase							:   int	):




 """simple docstring"""







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



def 						lowerCAmelCase		(		_lowerCAmelCase							:   list[list[int]]						,							_lowerCAmelCase							:   list[int]						,							_lowerCAmelCase							:   int						,							_lowerCAmelCase							:   int						,							):




 """simple docstring"""







 UpperCAmelCase__							 =						triangle[current_row_idx - 1][current_col_idx - 1]
 UpperCAmelCase__							 =						triangle[current_row_idx - 1][current_col_idx]
 UpperCAmelCase__							 =						above_to_left_elt + above_to_right_elt



def 						lowerCAmelCase		(		_lowerCAmelCase							:   int	):




 """simple docstring"""







 if not isinstance(_lowerCAmelCase						,							_lowerCAmelCase	):
  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"	)

 UpperCAmelCase__							 =						[[1]]

 for row_index in range(1						,							_lowerCAmelCase	):
  UpperCAmelCase__							 =						[0] + result[-1] + [0]
  UpperCAmelCase__							 =						row_index + 1
  # Calculate the number of distinct elements in a row
  UpperCAmelCase__							 =						sum(divmod(_lowerCAmelCase						,							2	)	)
  UpperCAmelCase__							 =						[
      temp_row[i - 1] + temp_row[i] for i in range(1						,							distinct_elements + 1	)
  ]
  UpperCAmelCase__							 =						row_first_half[: (row_index + 1) // 2]
  row_second_half.reverse()
  UpperCAmelCase__							 =						row_first_half + row_second_half
  result.append(_lowerCAmelCase	)

 return result



def 						lowerCAmelCase		(		):




 """simple docstring"""







 from collections.abc import Callable
 from timeit import timeit

 def benchmark_a_function(_lowerCAmelCase							:   Callable						,							_lowerCAmelCase							:   int	) -> None:
  UpperCAmelCase__							 =						F'''{func.__name__}({value})'''
  UpperCAmelCase__							 =						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(_lowerCAmelCase						,							_lowerCAmelCase	)
  print()


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  benchmark()











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


_lowerCAmelCase						:   Union[str, Any]		=   logging.get_logger(__name__)

_lowerCAmelCase						:   Tuple		=   {
    "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": (
        "https://huggingface.co/CarlCochet/trajectory-transformer-halfcheetah-medium-v2/resolve/main/config.json"
    ),
    # See all TrajectoryTransformer models at https://huggingface.co/models?filter=trajectory_transformer
}
class 			_UpperCamelCase      (				lowerCAmelCase		):
      UpperCAmelCase_        =		"""trajectory_transformer"""
      UpperCAmelCase_        =		["""past_key_values"""]
      UpperCAmelCase_        =		{
          """hidden_size""": """n_embd""",
          """num_attention_heads""": """n_head""",
          """num_hidden_layers""": """n_layer""",
      }
      def __init__(			self   :Union[str, Any] ,      lowerCamelCase   :Optional[int]=100 ,      lowerCamelCase   :Optional[int]=5 ,      lowerCamelCase   :Optional[Any]=1 ,      lowerCamelCase   :Any=1 ,      lowerCamelCase   :int=249 ,      lowerCamelCase   :Optional[Any]=6 ,      lowerCamelCase   :Optional[Any]=17 ,      lowerCamelCase   :Optional[int]=25 ,      lowerCamelCase   :Union[str, Any]=4 ,      lowerCamelCase   :Union[str, Any]=4 ,      lowerCamelCase   :Optional[int]=128 ,      lowerCamelCase   :List[Any]=0.1 ,      lowerCamelCase   :List[str]=0.1 ,      lowerCamelCase   :Tuple=0.1 ,      lowerCamelCase   :Dict=0.00_06 ,      lowerCamelCase   :Dict=512 ,      lowerCamelCase   :Optional[Any]=0.02 ,      lowerCamelCase   :Any=1e-12 ,      lowerCamelCase   :Optional[Any]=1 ,      lowerCamelCase   :List[Any]=True ,      lowerCamelCase   :int=1 ,      lowerCamelCase   :Dict=5_0256 ,      lowerCamelCase   :Union[str, Any]=5_0256 ,      **lowerCamelCase   :int ,      )     ->			Optional[Any]:
       UpperCAmelCase__							 =						vocab_size
       UpperCAmelCase__							 =						action_weight
       UpperCAmelCase__							 =						reward_weight
       UpperCAmelCase__							 =						value_weight
       UpperCAmelCase__							 =						max_position_embeddings
       UpperCAmelCase__							 =						block_size
       UpperCAmelCase__							 =						action_dim
       UpperCAmelCase__							 =						observation_dim
       UpperCAmelCase__							 =						transition_dim
       UpperCAmelCase__							 =						learning_rate
       UpperCAmelCase__							 =						n_layer
       UpperCAmelCase__							 =						n_head
       UpperCAmelCase__							 =						n_embd
       UpperCAmelCase__							 =						embd_pdrop
       UpperCAmelCase__							 =						attn_pdrop
       UpperCAmelCase__							 =						resid_pdrop
       UpperCAmelCase__							 =						initializer_range
       UpperCAmelCase__							 =						layer_norm_eps
       UpperCAmelCase__							 =						kaiming_initializer_range
       UpperCAmelCase__							 =						use_cache
       super().__init__(pad_token_id=lowerCamelCase ,      bos_token_id=lowerCamelCase ,      eos_token_id=lowerCamelCase ,      **lowerCamelCase      )





