




from collections import defaultdict


class    lowerCamelCase    :






			'''simple docstring'''





			def __init__( self			:   Union[str, Any]       ,						lowerCamelCase_			:   str       ,						lowerCamelCase_			:   List[Any]  )						->   Union[str, Any]:
								__magic_name__							:	Tuple    							=							total  # total no of tasks (N)

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

								__magic_name__							:	List[Any]    							=							defaultdict(lowerCamelCase_  )  # 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
								__magic_name__							:	Optional[int]    							=							(1 << len(lowerCamelCase_  )) - 1

			def 							UpperCAmelCase__       ( self			:   List[Any]       ,						lowerCamelCase_			:   Dict       ,						lowerCamelCase_			:   Any  )						->   List[Any]:
								# if mask == self.finalmask all persons are distributed tasks, return 1
								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
								__magic_name__							:	Optional[Any]    							=							self.count_ways_until(lowerCamelCase_       ,						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.
								__magic_name__							:	Union[str, Any]    							=							total_ways_util

								return self.dp[mask][task_no]


			def 							UpperCAmelCase__       ( self			:   str       ,						lowerCamelCase_			:   int  )						->   List[Any]:
								# Store the list of persons for each task
								for i in range(len(lowerCamelCase_  )  ):
													for j in task_performed[i]:
																		self.task[j].append(lowerCamelCase_  )

        # 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__":
	__lowerCamelCase   :						Union[str, Any]				=			5  # total no of tasks (the value of N)

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









from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


__lowerCamelCase   :						Optional[int]				=			logging.get_logger(__name__)

__lowerCamelCase   :						Tuple				=			{
    '''shi-labs/nat-mini-in1k-224''': '''https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json''',
    # See all Nat models at https://huggingface.co/models?filter=nat
}


class    lowerCamelCase    (		_lowerCamelCase				,_lowerCamelCase						):






			'''simple docstring'''





			UpperCamelCase__								='''nat'''

			UpperCamelCase__								={
			    '''num_attention_heads''': '''num_heads''',
			    '''num_hidden_layers''': '''num_layers''',
			}

			def __init__( self			:   Union[str, Any]       ,						lowerCamelCase_			:   Dict=4       ,						lowerCamelCase_			:   Union[str, Any]=3       ,						lowerCamelCase_			:   List[str]=64       ,						lowerCamelCase_			:   Union[str, Any]=[3, 4, 6, 5]       ,						lowerCamelCase_			:   List[Any]=[2, 4, 8, 16]       ,						lowerCamelCase_			:   List[Any]=7       ,						lowerCamelCase_			:   Union[str, Any]=3.0       ,						lowerCamelCase_			:   int=True       ,						lowerCamelCase_			:   str=0.0       ,						lowerCamelCase_			:   int=0.0       ,						lowerCamelCase_			:   Dict=0.1       ,						lowerCamelCase_			:   Optional[int]="gelu"       ,						lowerCamelCase_			:   Tuple=0.0_2       ,						lowerCamelCase_			:   Tuple=1E-5       ,						lowerCamelCase_			:   List[Any]=0.0       ,						lowerCamelCase_			:   str=None       ,						lowerCamelCase_			:   Tuple=None       ,						**lowerCamelCase_			:   Any       ,						)						->   Any:
								super().__init__(**lowerCamelCase_  )

								__magic_name__							:	List[Any]    							=							patch_size
								__magic_name__							:	str    							=							num_channels
								__magic_name__							:	Union[str, Any]    							=							embed_dim
								__magic_name__							:	Dict    							=							depths
								__magic_name__							:	str    							=							len(lowerCamelCase_  )
								__magic_name__							:	List[str]    							=							num_heads
								__magic_name__							:	Optional[int]    							=							kernel_size
								__magic_name__							:	Any    							=							mlp_ratio
								__magic_name__							:	Any    							=							qkv_bias
								__magic_name__							:	Union[str, Any]    							=							hidden_dropout_prob
								__magic_name__							:	Any    							=							attention_probs_dropout_prob
								__magic_name__							:	List[str]    							=							drop_path_rate
								__magic_name__							:	str    							=							hidden_act
								__magic_name__							:	Tuple    							=							layer_norm_eps
								__magic_name__							:	Any    							=							initializer_range
								# we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
								# this indicates the channel dimension after the last stage of the model
								__magic_name__							:	str    							=							int(embed_dim * 2 ** (len(lowerCamelCase_  ) - 1)  )
								__magic_name__							:	str    							=							layer_scale_init_value
								__magic_name__							:	Dict    							=							['''stem'''] + [F'''stage{idx}''' for idx in range(1       ,						len(lowerCamelCase_  ) + 1  )]
								__magic_name__							,    __magic_name__							:	int    							=							get_aligned_output_features_output_indices(
								    out_features=lowerCamelCase_       ,						out_indices=lowerCamelCase_       ,						stage_names=self.stage_names  )



