


'''simple docstring'''
import argparse
from argparse import Namespace

import torch
from torch import nn

from transformers import XGLMConfig, XGLMForCausalLM


def 			a      (			__a   )  ->	Dict:



					'''simple docstring'''






					UpperCamelCase__   :List[Any]												= [
					    '''decoder.version''',
					    '''decoder.output_projection.weight''',
					    '''_float_tensor''',
					    '''decoder.embed_positions._float_tensor''',
					]
					for k in ignore_keys:
										state_dict.pop(__a ,					__a   )


def 			a      (			__a   )  ->	List[Any]:



					'''simple docstring'''






					UpperCamelCase__					,				UpperCamelCase__   :int												= emb.weight.shape
					UpperCamelCase__   :Tuple												= nn.Linear(__a ,					__a ,					bias=__a   )
					UpperCamelCase__   :Dict												= emb.weight.data
					return lin_layer


def 			a      (			__a   )  ->	str:



					'''simple docstring'''






					UpperCamelCase__   :int												= torch.load(__a ,					map_location='''cpu'''   )
					UpperCamelCase__   :Optional[int]												= Namespace(**checkpoint['''cfg''']['''model''']   )
					UpperCamelCase__   :Dict												= checkpoint['''model''']
					remove_ignore_keys_(__a   )
					UpperCamelCase__   :Optional[int]												= state_dict['''decoder.embed_tokens.weight'''].shape[0]

					UpperCamelCase__   :Optional[int]												= {key.replace('''decoder''' ,					'''model'''   ): val for key, val in state_dict.items()}

					UpperCamelCase__   :Union[str, Any]												= XGLMConfig(
					    vocab_size=__a ,					max_position_embeddings=args.max_target_positions ,					num_layers=args.decoder_layers ,					attention_heads=args.decoder_attention_heads ,					ffn_dim=args.decoder_ffn_embed_dim ,					d_model=args.decoder_embed_dim ,					layerdrop=args.decoder_layerdrop ,					dropout=args.dropout ,					attention_dropout=args.attention_dropout ,					activation_dropout=args.activation_dropout ,					activation_function='''gelu''' ,					scale_embedding=not args.no_scale_embedding ,					tie_word_embeddings=args.share_decoder_input_output_embed ,					)

					UpperCamelCase__   :Any												= XGLMForCausalLM(__a   )
					UpperCamelCase__   :Dict												= model.load_state_dict(__a ,					strict=__a   )
					print(__a   )
					UpperCamelCase__   :Optional[int]												= make_linear_from_emb(model.model.embed_tokens   )

					return model


if __name__ == "__main__":
		__snake_case							      =     argparse.ArgumentParser()
		# Required parameters
		parser.add_argument('''fairseq_path''', type=str, help='''path to a model.pt on local filesystem.''')
		parser.add_argument('''pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model.''')
		__snake_case							      =     parser.parse_args()
		__snake_case							      =     convert_fairseq_xglm_checkpoint_from_disk(args.fairseq_path)
		model.save_pretrained(args.pytorch_dump_folder_path)



'''simple docstring'''
from collections import defaultdict
class    lowercase	:

		"""simple docstring"""

		def __init__(		self    ,   UpperCamelCase_    ,   UpperCamelCase_							):

							'''simple docstring'''


							UpperCamelCase__   :List[Any]												= total  # total no of tasks (N)

							# DP table will have a dimension of (2^M)*N
							# initially all values are set to -1
							UpperCamelCase__   :Union[str, Any]												= [
							    [-1 for i in range(total + 1							)] for j in range(2 ** len(UpperCamelCase_							)							)
							]

							UpperCamelCase__   :str												= defaultdict(UpperCamelCase_							)  # 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
							UpperCamelCase__   :Optional[int]												= (1 << len(UpperCamelCase_							)) - 1




		def     lowerCAmelCase__				(		self    ,   UpperCamelCase_    ,   UpperCamelCase_							):

							'''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
							UpperCamelCase__   :str												= self.count_ways_until(UpperCamelCase_    ,   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.
							UpperCamelCase__   :Optional[int]												= total_ways_util

							return self.dp[mask][task_no]




		def     lowerCAmelCase__				(		self    ,   UpperCamelCase_							):

							'''simple docstring'''


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

        # 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__":
		__snake_case							      =     5  # total no of tasks (the value of N)

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