






'''simple docstring'''
from typing import List, Optional, Union

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


UpperCamelCase__			=      logging.get_logger(__name__)

UpperCamelCase__			=      {
    'huggingface/time-series-transformer-tourism-monthly': (
        'https://huggingface.co/huggingface/time-series-transformer-tourism-monthly/resolve/main/config.json'
    ),
    # See all TimeSeriesTransformer models at https://huggingface.co/models?filter=time_series_transformer
}


class 							_UpperCAmelCase    (		__A      ):
    __lowerCamelCase: Optional[int]									=     'time_series_transformer'
    __lowerCamelCase: str									=     {
        'hidden_size': 'd_model',
        'num_attention_heads': 'encoder_attention_heads',
        'num_hidden_layers': 'encoder_layers',
    }




    def __init__(      self	:							List[str]	,  a	:							Any = None	,  a	:							int = None	,  a	:							str = "student_t"	,  a	:							Dict = "nll"	,  a	:							str = 1	,  a	:							int = [1, 2, 3, 4, 5, 6, 7]	,  a	:							List[Any] = "mean"	,  a	:							Tuple = 0	,  a	:							int = 0	,  a	:							Dict = 0	,  a	:							List[str] = 0	,  a	:							Dict = None	,  a	:							List[Any] = None	,  a	:							Optional[Any] = 3_2	,  a	:							Optional[int] = 3_2	,  a	:							Any = 2	,  a	:							Optional[int] = 2	,  a	:							str = 2	,  a	:							List[Any] = 2	,  a	:							Union[str, Any] = True	,  a	:							Any = "gelu"	,  a	:							Tuple = 6_4	,  a	:							Dict = 0.1	,  a	:							List[str] = 0.1	,  a	:							Optional[Any] = 0.1	,  a	:							int = 0.1	,  a	:							str = 0.1	,  a	:							str = 1_0_0	,  a	:							int = 0.02	,  a	:							Dict=True	,  **a	:							Union[str, Any]	,  ):






       '''simple docstring'''






       lowercase_						:     int							     =  prediction_length
       lowercase_						:     int							     =  context_length or prediction_length
       lowercase_						:     Union[str, Any]							     =  distribution_output
       lowercase_						:     Optional[int]							     =  loss
       lowercase_						:     Tuple							     =  input_size
       lowercase_						:     int							     =  num_time_features
       lowercase_						:     Optional[Any]							     =  lags_sequence
       lowercase_						:     Dict							     =  scaling
       lowercase_						:     Union[str, Any]							     =  num_dynamic_real_features
       lowercase_						:     List[Any]							     =  num_static_real_features
       lowercase_						:     Optional[int]							     =  num_static_categorical_features
       if cardinality and num_static_categorical_features > 0:
          if len(snake_case_      ) != num_static_categorical_features:
             raise ValueError(
                 "The cardinality should be a list of the same length as `num_static_categorical_features`"      )
          lowercase_						:     str							     =  cardinality
       else:
          lowercase_						:     List[str]							     =  [0]
       if embedding_dimension and num_static_categorical_features > 0:
          if len(snake_case_      ) != num_static_categorical_features:
             raise ValueError(
                 "The embedding dimension should be a list of the same length as `num_static_categorical_features`"      )
          lowercase_						:     Tuple							     =  embedding_dimension
       else:
          lowercase_						:     Dict							     =  [min(5_0	,  (cat + 1) // 2      ) for cat in self.cardinality]
       lowercase_						:     List[str]							     =  num_parallel_samples

       # Transformer architecture configuration
       lowercase_						:     Union[str, Any]							     =  input_size * len(snake_case_      ) + self._number_of_features
       lowercase_						:     Any							     =  d_model
       lowercase_						:     Dict							     =  encoder_attention_heads
       lowercase_						:     List[Any]							     =  decoder_attention_heads
       lowercase_						:     Optional[int]							     =  encoder_ffn_dim
       lowercase_						:     Dict							     =  decoder_ffn_dim
       lowercase_						:     str							     =  encoder_layers
       lowercase_						:     int							     =  decoder_layers

       lowercase_						:     int							     =  dropout
       lowercase_						:     str							     =  attention_dropout
       lowercase_						:     Any							     =  activation_dropout
       lowercase_						:     List[Any]							     =  encoder_layerdrop
       lowercase_						:     Optional[Any]							     =  decoder_layerdrop

       lowercase_						:     Optional[Any]							     =  activation_function
       lowercase_						:     Optional[int]							     =  init_std

       lowercase_						:     List[Any]							     =  use_cache

       super().__init__(is_encoder_decoder=snake_case_	,  **snake_case_      )





    @property
    def 					lowerCAmelCase__					(      self	:							Dict      ):






       '''simple docstring'''






       return (
           sum(self.embedding_dimension      )
           + self.num_dynamic_real_features
           + self.num_time_features
           + self.num_static_real_features
           + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
       )





"""simple docstring"""



from collections import defaultdict
class 						__UpperCAmelCase    :







			'''simple docstring'''





			def __init__(			self   ,      snake_case_   ,      snake_case_							):







										'''simple docstring'''


										A__       :     Tuple								=			total  # total no of tasks (N)

										# DP table will have a dimension of (2^M)*N
										# initially all values are set to -1
										A__       :     Optional[int]								=			[
										    [-1 for i in range(total + 1							)] for j in range(2 ** len(snake_case_							)							)
										]

										A__       :     Optional[int]								=			defaultdict(snake_case_							)  # stores the list of persons for each task

										# final_mask is used to check if all persons are included by setting all bits
										# to 1
										A__       :     Optional[int]								=			(1 << len(snake_case_							)) - 1





			def 		lowerCamelCase					(			self   ,      snake_case_   ,      snake_case_							):







										'''simple docstring'''


										if mask == self.final_mask:
																	return 1

										# if not everyone gets the task and no more tasks are available, return 0
										if task_no > self.total_tasks:
																	return 0

										# if case already considered
										if self.dp[mask][task_no] != -1:
																	return self.dp[mask][task_no]

										# Number of ways when we don't this task in the arrangement
										A__       :     Optional[int]								=			self.count_ways_until(snake_case_   ,      task_no + 1							)

										# now assign the tasks one by one to all possible persons and recursively
										# assign for the remaining tasks.
										if task_no in self.task:
																	for p in self.task[task_no]:
																								# if p is already given a task
																								if mask & (1 << p):
																															continue

																								# assign this task to p and change the mask value. And recursively
																								# assign tasks with the new mask value.
																								total_ways_util += self.count_ways_until(mask | (1 << p)   ,      task_no + 1							)

        # save the value.
										A__       :     List[str]								=			total_ways_util

										return self.dp[mask][task_no]





			def 		lowerCamelCase					(			self   ,      snake_case_							):







										'''simple docstring'''


										for i in range(len(snake_case_							)							):
																	for j in task_performed[i]:
																								self.task[j].append(snake_case_							)

        # call the function to fill the DP table, final answer is stored in dp[0][1]
										return self.count_ways_until(0   ,      1							)


if __name__ == "__main__":
				_UpperCamelCase								=		5  # total no of tasks (the value of N)

				# the list of tasks that can be done by M persons.
				_UpperCamelCase								=		[[1, 3, 4], [1, 2, 5], [3, 4]]
				print(
				    AssignmentUsingBitmask(task_performed, total_tasks).count_no_of_ways(
				        task_performed
				    )
				)





