

'''simple docstring'''


def 						SCREAMING_SNAKE_CASE(  )    ->    List[str]:
	UpperCAmelCase_		:      int       	=					[3_1, 2_8, 3_1, 3_0, 3_1, 3_0, 3_1, 3_1, 3_0, 3_1, 3_0, 3_1]

	UpperCAmelCase_		:      Union[str, Any]       	=					6
	UpperCAmelCase_		:      List[str]       	=					1
	UpperCAmelCase_		:      Dict       	=					1_9_0_1

	UpperCAmelCase_		:      Optional[Any]       	=					0

	while year < 2_0_0_1:
		day += 7

		if (year % 4 == 0 and year % 1_0_0 != 0) or (year % 4_0_0 == 0):
			if day > days_per_month[month - 1] and month != 2:
				month += 1
				UpperCAmelCase_		:      Union[str, Any]       	=					day - days_per_month[month - 2]
			elif day > 2_9 and month == 2:
				month += 1
				UpperCAmelCase_		:      List[str]       	=					day - 2_9
		else:
			if day > days_per_month[month - 1]:
				month += 1
				UpperCAmelCase_		:      str       	=					day - days_per_month[month - 2]

		if month > 1_2:
			year += 1
			UpperCAmelCase_		:      Any       	=					1

		if year < 2_0_0_1 and day == 1:
			sundays += 1
	return sundays


if __name__ == "__main__":
						print(solution())









'''simple docstring'''


import argparse

import torch

from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration
from transformers.utils import logging


logging.set_verbosity_info()
lowerCAmelCase__										= logging.get_logger(__name__)

lowerCAmelCase__										= [
    ["attention", "attn"],
    ["encoder_attention", "encoder_attn"],
    ["q_lin", "q_proj"],
    ["k_lin", "k_proj"],
    ["v_lin", "v_proj"],
    ["out_lin", "out_proj"],
    ["norm_embeddings", "layernorm_embedding"],
    ["position_embeddings", "embed_positions"],
    ["embeddings", "embed_tokens"],
    ["ffn.lin", "fc"],
]







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase  )    ->    List[Any]:
	if k == "embeddings.weight":
		return "shared.weight"

	for parlai_name, hf_name in PATTERNS:
		UpperCAmelCase_		:      Optional[int]       	=					k.replace(UpperCamelCase   ,UpperCamelCase  )

	if k.startswith('encoder'  ):
		UpperCAmelCase_		:      Dict       	=					k.replace('.attn'   ,'.self_attn'  )
		UpperCAmelCase_		:      int       	=					k.replace('norm1'   ,'self_attn_layer_norm'  )
		UpperCAmelCase_		:      int       	=					k.replace('norm2'   ,'final_layer_norm'  )
	elif k.startswith('decoder'  ):
		UpperCAmelCase_		:      Union[str, Any]       	=					k.replace('norm1'   ,'self_attn_layer_norm'  )
		UpperCAmelCase_		:      int       	=					k.replace('norm2'   ,'encoder_attn_layer_norm'  )
		UpperCAmelCase_		:      List[str]       	=					k.replace('norm3'   ,'final_layer_norm'  )
	return k







def 						SCREAMING_SNAKE_CASE(  UpperCamelCase  )    ->    Optional[Any]:
	UpperCAmelCase_		:      Union[str, Any]       	=					[
	    'model.encoder.layernorm_embedding.weight',
	    'model.encoder.layernorm_embedding.bias',
	    'model.decoder.layernorm_embedding.weight',
	    'model.decoder.layernorm_embedding.bias',
	]
	for k in keys:
		UpperCAmelCase_		:      Optional[int]       	=					sd.pop(UpperCamelCase  )
		UpperCAmelCase_		:      List[Any]       	=					k.replace('layernorm_embedding'   ,'layer_norm'  )
		assert new_k not in sd
		UpperCAmelCase_		:      Any       	=					v


lowerCAmelCase__										= ["START"]







@torch.no_grad()
def 						SCREAMING_SNAKE_CASE(  UpperCamelCase   ,UpperCamelCase   ,UpperCamelCase  )    ->    Dict:
	UpperCAmelCase_		:      str       	=					torch.load(UpperCamelCase   ,map_location='cpu'  )
	UpperCAmelCase_		:      Tuple       	=					model['model']
	UpperCAmelCase_		:      Union[str, Any]       	=					BlenderbotConfig.from_json_file(UpperCamelCase  )
	UpperCAmelCase_		:      Union[str, Any]       	=					BlenderbotForConditionalGeneration(UpperCamelCase  )
	UpperCAmelCase_		:      Union[str, Any]       	=					m.model.state_dict().keys()
	UpperCAmelCase_		:      Optional[Any]       	=					[]
	UpperCAmelCase_		:      Dict       	=					{}
	for k, v in sd.items():
		if k in IGNORE_KEYS:
			continue

		UpperCAmelCase_		:      Union[str, Any]       	=					rename_state_dict_key(UpperCamelCase  )
		if new_k not in valid_keys:
			failures.append([k, new_k]  )
		else:
			UpperCAmelCase_		:      List[str]       	=					v
	if cfg.normalize_before:  # Blenderbot-3B checkpoints. Rename layernorm_embedding -> layer_norm
		rename_layernorm_keys(UpperCamelCase  )
	m.model.load_state_dict(UpperCamelCase   ,strict=UpperCamelCase  )
	m.half()
	m.save_pretrained(UpperCamelCase  )


if __name__ == "__main__":
						lowerCAmelCase__										= argparse.ArgumentParser()
						# Required parameters
						parser.add_argument("--src_path", type=str, help="like blenderbot-model.bin")
						parser.add_argument("--save_dir", default="hf_blenderbot", type=str, help="Where to save converted model.")
						parser.add_argument(
						    "--hf_config_json", default="blenderbot-3b-config.json", type=str, help="Path to config to use"
						)
						lowerCAmelCase__										= parser.parse_args()
						convert_parlai_checkpoint(args.src_path, args.save_dir, args.hf_config_json)






