






'''simple docstring'''







from collections import defaultdict




class 		UpperCamelCase__    :




		'''simple docstring'''





		def __init__(      self   ,_lowerCAmelCase   ,_lowerCAmelCase       ):
								lowerCamelCase__         =  total  # total no of tasks (N)

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

								lowerCamelCase__         =  defaultdict(__a       )  # 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
								lowerCamelCase__         =  (1 << len(__a       )) - 1






		def 			UpperCamelCase_					(      self   ,_lowerCAmelCase   ,_lowerCAmelCase       ):
								# 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
								lowerCamelCase__         =  self.count_ways_until(__a   ,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.
								lowerCamelCase__         =  total_ways_util

								return self.dp[mask][task_no]






		def 			UpperCamelCase_					(      self   ,_lowerCAmelCase       ):
								# Store the list of persons for each task
								for i in range(len(__a       )       ):
														for j in task_performed[i]:
																				self.task[j].append(__a       )

        # 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    :      Optional[Any]  			=		5  # total no of tasks (the value of N)

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









'''simple docstring'''







import argparse

import torch
from torch import nn

from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration
def 						A__			(				__lowerCAmelCase		:			Union[str, Any]						):
						lowerCamelCase__         =  [
						    """encoder.version""",
						    """decoder.version""",
						    """model.encoder.version""",
						    """model.decoder.version""",
						    """decoder.output_projection.weight""",
						    """_float_tensor""",
						    """encoder.embed_positions._float_tensor""",
						    """decoder.embed_positions._float_tensor""",
						]
						for k in ignore_keys:
												state_dict.pop(__lowerCAmelCase   ,    __lowerCAmelCase						)
def 						A__			(				__lowerCAmelCase		:			Tuple						):
						lowerCamelCase__       ,			lowerCamelCase__         =  emb.weight.shape
						lowerCamelCase__         =  nn.Linear(__lowerCAmelCase   ,    __lowerCAmelCase   ,    bias=__lowerCAmelCase						)
						lowerCamelCase__         =  emb.weight.data
						return lin_layer
def 						A__			(				__lowerCAmelCase		:			Dict						):
						lowerCamelCase__         =  torch.load(__lowerCAmelCase   ,    map_location="""cpu"""						)
						lowerCamelCase__         =  mam_aaa["""args"""] or mam_aaa["""cfg"""]["""model"""]
						lowerCamelCase__         =  mam_aaa["""model"""]
						remove_ignore_keys_(__lowerCAmelCase						)
						lowerCamelCase__         =  state_dict["""encoder.embed_tokens.weight"""].shape[0]

						lowerCamelCase__         =  MaMaaaConfig(
						    vocab_size=__lowerCAmelCase   ,    max_position_embeddings=1024   ,    encoder_layers=args.encoder_layers   ,    decoder_layers=args.decoder_layers   ,    encoder_attention_heads=args.encoder_attention_heads   ,    decoder_attention_heads=args.decoder_attention_heads   ,    encoder_ffn_dim=args.encoder_ffn_embed_dim   ,    decoder_ffn_dim=args.decoder_ffn_embed_dim   ,    d_model=args.encoder_embed_dim   ,    encoder_layerdrop=args.encoder_layerdrop   ,    decoder_layerdrop=args.decoder_layerdrop   ,    dropout=args.dropout   ,    attention_dropout=args.attention_dropout   ,    activation_dropout=args.activation_dropout   ,    activation_function="""relu"""   ,    )

						lowerCamelCase__         =  state_dict["""decoder.embed_tokens.weight"""]
						lowerCamelCase__         =  MaMaaaForConditionalGeneration(__lowerCAmelCase						)
						model.model.load_state_dict(__lowerCAmelCase   ,    strict=__lowerCAmelCase						)
						lowerCamelCase__         =  make_linear_from_emb(model.model.shared						)

						return model


if __name__ == "__main__":
							UpperCamelCase    :      Optional[Any]  			=		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.')
							UpperCamelCase    :      Tuple  			=		parser.parse_args()
							UpperCamelCase    :      List[Any]  			=		convert_fairseq_mamaaa_checkpoint_from_disk(args.fairseq_pathß)
							model.save_pretrained(args.pytorch_dump_folder_path)

