



'''simple docstring'''





import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import (
    BertTokenizer,
    ViltConfig,
    ViltForImageAndTextRetrieval,
    ViltForImagesAndTextClassification,
    ViltForMaskedLM,
    ViltForQuestionAnswering,
    ViltImageProcessor,
    ViltProcessor,
)
from transformers.utils import logging


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





def 						__snake_case(				_lowerCAmelCase     ,   _lowerCAmelCase=False     ,   _lowerCAmelCase=False     ,   _lowerCAmelCase=False		)		-> Union[str, Any]:
      snake_case__  :    str    						=      []
      for i in range(config.num_hidden_layers		):
            # encoder layers: output projection, 2 feedforward neural networks and 2 layernorms
            rename_keys.append((f"transformer.blocks.{i}.norm1.weight", f"vilt.encoder.layer.{i}.layernorm_before.weight")		)
            rename_keys.append((f"transformer.blocks.{i}.norm1.bias", f"vilt.encoder.layer.{i}.layernorm_before.bias")		)
            rename_keys.append(
                (f"transformer.blocks.{i}.attn.proj.weight", f"vilt.encoder.layer.{i}.attention.output.dense.weight")		)
            rename_keys.append(
                (f"transformer.blocks.{i}.attn.proj.bias", f"vilt.encoder.layer.{i}.attention.output.dense.bias")		)
            rename_keys.append((f"transformer.blocks.{i}.norm2.weight", f"vilt.encoder.layer.{i}.layernorm_after.weight")		)
            rename_keys.append((f"transformer.blocks.{i}.norm2.bias", f"vilt.encoder.layer.{i}.layernorm_after.bias")		)
            rename_keys.append(
                (f"transformer.blocks.{i}.mlp.fc1.weight", f"vilt.encoder.layer.{i}.intermediate.dense.weight")		)
            rename_keys.append((f"transformer.blocks.{i}.mlp.fc1.bias", f"vilt.encoder.layer.{i}.intermediate.dense.bias")		)
            rename_keys.append((f"transformer.blocks.{i}.mlp.fc2.weight", f"vilt.encoder.layer.{i}.output.dense.weight")		)
            rename_keys.append((f"transformer.blocks.{i}.mlp.fc2.bias", f"vilt.encoder.layer.{i}.output.dense.bias")		)

      # embeddings
      rename_keys.extend(
          [
              # text embeddings
              ("""text_embeddings.word_embeddings.weight""", """vilt.embeddings.text_embeddings.word_embeddings.weight"""),
              (
                  """text_embeddings.position_embeddings.weight""",
                  """vilt.embeddings.text_embeddings.position_embeddings.weight""",
              ),
              ("""text_embeddings.position_ids""", """vilt.embeddings.text_embeddings.position_ids"""),
              (
                  """text_embeddings.token_type_embeddings.weight""",
                  """vilt.embeddings.text_embeddings.token_type_embeddings.weight""",
              ),
              ("""text_embeddings.LayerNorm.weight""", """vilt.embeddings.text_embeddings.LayerNorm.weight"""),
              ("""text_embeddings.LayerNorm.bias""", """vilt.embeddings.text_embeddings.LayerNorm.bias"""),
              # patch embeddings
              ("""transformer.cls_token""", """vilt.embeddings.cls_token"""),
              ("""transformer.patch_embed.proj.weight""", """vilt.embeddings.patch_embeddings.projection.weight"""),
              ("""transformer.patch_embed.proj.bias""", """vilt.embeddings.patch_embeddings.projection.bias"""),
              ("""transformer.pos_embed""", """vilt.embeddings.position_embeddings"""),
              # token type embeddings
              ("""token_type_embeddings.weight""", """vilt.embeddings.token_type_embeddings.weight"""),
          ]		)

      # final layernorm + pooler
      rename_keys.extend(
          [
              ("""transformer.norm.weight""", """vilt.layernorm.weight"""),
              ("""transformer.norm.bias""", """vilt.layernorm.bias"""),
              ("""pooler.dense.weight""", """vilt.pooler.dense.weight"""),
              ("""pooler.dense.bias""", """vilt.pooler.dense.bias"""),
          ]		)

      # classifier head(s)
      if vqa_model:
            # classification head
            rename_keys.extend(
                [
                    ("""vqa_classifier.0.weight""", """classifier.0.weight"""),
                    ("""vqa_classifier.0.bias""", """classifier.0.bias"""),
                    ("""vqa_classifier.1.weight""", """classifier.1.weight"""),
                    ("""vqa_classifier.1.bias""", """classifier.1.bias"""),
                    ("""vqa_classifier.3.weight""", """classifier.3.weight"""),
                    ("""vqa_classifier.3.bias""", """classifier.3.bias"""),
                ]		)
      elif nlvr_model:
            # classification head
            rename_keys.extend(
                [
                    ("""nlvr2_classifier.0.weight""", """classifier.0.weight"""),
                    ("""nlvr2_classifier.0.bias""", """classifier.0.bias"""),
                    ("""nlvr2_classifier.1.weight""", """classifier.1.weight"""),
                    ("""nlvr2_classifier.1.bias""", """classifier.1.bias"""),
                    ("""nlvr2_classifier.3.weight""", """classifier.3.weight"""),
                    ("""nlvr2_classifier.3.bias""", """classifier.3.bias"""),
                ]		)
      else:
            pass

      return rename_keys





def 						__snake_case(				_lowerCAmelCase     ,   _lowerCAmelCase		)		-> Optional[Any]:
      for i in range(config.num_hidden_layers		):
            snake_case__  :    str    						=      """vilt."""
            # read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
            snake_case__  :    List[str]    						=      state_dict.pop(f"transformer.blocks.{i}.attn.qkv.weight"		)
            snake_case__  :    str    						=      state_dict.pop(f"transformer.blocks.{i}.attn.qkv.bias"		)
            # next, add query, keys and values (in that order) to the state dict
            snake_case__  :    Union[str, Any]    						=      in_proj_weight[
                : config.hidden_size, :
            ]
            snake_case__  :    Union[str, Any]    						=      in_proj_bias[: config.hidden_size]
            snake_case__  :    Optional[int]    						=      in_proj_weight[
                config.hidden_size : config.hidden_size * 2, :
            ]
            snake_case__  :    Tuple    						=      in_proj_bias[
                config.hidden_size : config.hidden_size * 2
            ]
            snake_case__  :    Optional[int]    						=      in_proj_weight[
                -config.hidden_size :, :
            ]
            snake_case__  :    List[str]    						=      in_proj_bias[-config.hidden_size :]





def 						__snake_case(				_lowerCAmelCase		)		-> Any:
      snake_case__  :    Dict    						=      ["""head.weight""", """head.bias"""]
      for k in ignore_keys:
            state_dict.pop(_lowerCAmelCase     ,   _lowerCAmelCase		)





def 						__snake_case(				_lowerCAmelCase     ,   _lowerCAmelCase     ,   _lowerCAmelCase		)		-> Dict:
      snake_case__  :    int    						=      dct.pop(_lowerCAmelCase		)
      snake_case__  :    Optional[Any]    						=      val





@torch.no_grad()
def 						__snake_case(				_lowerCAmelCase     ,   _lowerCAmelCase		)		-> Tuple:
      snake_case__  :    List[str]    						=      ViltConfig(image_size=384     ,   patch_size=32     ,   tie_word_embeddings=_lowerCAmelCase		)
      snake_case__  :    Union[str, Any]    						=      False
      snake_case__  :    List[str]    						=      False
      snake_case__  :    Any    						=      False
      snake_case__  :    int    						=      False
      if "vqa" in checkpoint_url:
            snake_case__  :    List[Any]    						=      True
            snake_case__  :    Any    						=      3_129
            snake_case__  :    Tuple    						=      """huggingface/label-files"""
            snake_case__  :    List[str]    						=      """vqa2-id2label.json"""
            snake_case__  :    str    						=      json.load(open(hf_hub_download(_lowerCAmelCase     ,   _lowerCAmelCase     ,   repo_type="""dataset"""		)     ,   """r"""		)		)
            snake_case__  :    Any    						=      {int(_lowerCAmelCase		): v for k, v in idalabel.items()}
            snake_case__  :    Union[str, Any]    						=      idalabel
            snake_case__  :    int    						=      {v: k for k, v in idalabel.items()}
            snake_case__  :    Tuple    						=      ViltForQuestionAnswering(_lowerCAmelCase		)
      elif "nlvr" in checkpoint_url:
            snake_case__  :    Optional[Any]    						=      True
            snake_case__  :    List[Any]    						=      2
            snake_case__  :    Any    						=      {0: """False""", 1: """True"""}
            snake_case__  :    int    						=      {v: k for k, v in config.idalabel.items()}
            snake_case__  :    Any    						=      3
            snake_case__  :    List[str]    						=      ViltForImagesAndTextClassification(_lowerCAmelCase		)
      elif "irtr" in checkpoint_url:
            snake_case__  :    List[str]    						=      True
            snake_case__  :    Optional[int]    						=      ViltForImageAndTextRetrieval(_lowerCAmelCase		)
      elif "mlm_itm" in checkpoint_url:
            snake_case__  :    Optional[Any]    						=      True
            snake_case__  :    Optional[Any]    						=      ViltForMaskedLM(_lowerCAmelCase		)
      else:
            raise ValueError("""Unknown model type"""		)

      # load state_dict of original model, remove and rename some keys
      snake_case__  :    Dict    						=      torch.hub.load_state_dict_from_url(_lowerCAmelCase     ,   map_location="""cpu"""		)["""state_dict"""]
      snake_case__  :    List[Any]    						=      create_rename_keys(_lowerCAmelCase     ,   _lowerCAmelCase     ,   _lowerCAmelCase     ,   _lowerCAmelCase		)
      for src, dest in rename_keys:
            rename_key(_lowerCAmelCase     ,   _lowerCAmelCase     ,   _lowerCAmelCase		)
      read_in_q_k_v(_lowerCAmelCase     ,   _lowerCAmelCase		)
      if mlm_model or irtr_model:
            snake_case__  :    List[str]    						=      ["""itm_score.fc.weight""", """itm_score.fc.bias"""]
            for k in ignore_keys:
                  state_dict.pop(_lowerCAmelCase     ,   _lowerCAmelCase		)

    # load state dict into HuggingFace model
      model.eval()
      if mlm_model:
            snake_case__  :    List[Any]    						=      model.load_state_dict(_lowerCAmelCase     ,   strict=_lowerCAmelCase		)
            assert missing_keys == ["mlm_score.decoder.bias"]
      else:
            model.load_state_dict(_lowerCAmelCase		)

      # Define processor
      snake_case__  :    Optional[int]    						=      ViltImageProcessor(size=384		)
      snake_case__  :    List[str]    						=      BertTokenizer.from_pretrained("""bert-base-uncased"""		)
      snake_case__  :    Union[str, Any]    						=      ViltProcessor(_lowerCAmelCase     ,   _lowerCAmelCase		)

      # Forward pass on example inputs (image + text)
      if nlvr_model:
            snake_case__  :    int    						=      Image.open(requests.get("""https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg"""     ,   stream=_lowerCAmelCase		).raw		)
            snake_case__  :    int    						=      Image.open(requests.get("""https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg"""     ,   stream=_lowerCAmelCase		).raw		)
            snake_case__  :    Dict    						=      (
                """The left image contains twice the number of dogs as the right image, and at least two dogs in total are"""
                """ standing."""
            )
            snake_case__  :    Optional[int]    						=      processor(_lowerCAmelCase     ,   _lowerCAmelCase     ,   return_tensors="""pt"""		)
            snake_case__  :    Dict    						=      processor(_lowerCAmelCase     ,   _lowerCAmelCase     ,   return_tensors="""pt"""		)
            snake_case__  :    List[str]    						=      model(
                input_ids=encoding_a.input_ids     ,   pixel_values=encoding_a.pixel_values     ,   pixel_values_a=encoding_a.pixel_values     ,   )
      else:
            snake_case__  :    str    						=      Image.open(requests.get("""http://images.cocodataset.org/val2017/000000039769.jpg"""     ,   stream=_lowerCAmelCase		).raw		)
            if mlm_model:
                  snake_case__  :    str    						=      """a bunch of [MASK] laying on a [MASK]."""
            else:
                  snake_case__  :    Optional[int]    						=      """How many cats are there?"""
            snake_case__  :    List[str]    						=      processor(_lowerCAmelCase     ,   _lowerCAmelCase     ,   return_tensors="""pt"""		)
            snake_case__  :    Union[str, Any]    						=      model(**_lowerCAmelCase		)

      # Verify outputs
      if mlm_model:
            snake_case__  :    Tuple    						=      torch.Size([1, 11, 30_522]		)
            snake_case__  :    int    						=      torch.tensor([-12.5061, -12.5123, -12.5174]		)
            assert outputs.logits.shape == expected_shape
            assert torch.allclose(outputs.logits[0, 0, :3]     ,   _lowerCAmelCase     ,   atol=1e-4		)

            # verify masked token prediction equals "cats"
            snake_case__  :    int    						=      outputs.logits[0, 4, :].argmax(-1		).item()
            assert tokenizer.decode([predicted_id]		) == "cats"
      elif vqa_model:
            snake_case__  :    str    						=      torch.Size([1, 3_129]		)
            snake_case__  :    Any    						=      torch.tensor([-15.9495, -18.1472, -10.3041]		)
            assert torch.allclose(outputs.logits[0, :3]     ,   _lowerCAmelCase     ,   atol=1e-4		)
            assert outputs.logits.shape == expected_shape
            assert torch.allclose(outputs.logits[0, 0, :3]     ,   _lowerCAmelCase     ,   atol=1e-4		)

            # verify vqa prediction equals "2"
            snake_case__  :    Tuple    						=      outputs.logits.argmax(-1		).item()
            assert model.config.idalabel[predicted_idx] == "2"
      elif nlvr_model:
            snake_case__  :    str    						=      torch.Size([1, 2]		)
            snake_case__  :    Optional[Any]    						=      torch.tensor([-2.8721, 2.1291]		)
            assert torch.allclose(outputs.logits[0, :3]     ,   _lowerCAmelCase     ,   atol=1e-4		)
            assert outputs.logits.shape == expected_shape

      Path(_lowerCAmelCase		).mkdir(exist_ok=_lowerCAmelCase		)
      print(f"Saving model and processor to {pytorch_dump_folder_path}"		)
      model.save_pretrained(_lowerCAmelCase		)
      processor.save_pretrained(_lowerCAmelCase		)


if __name__ == "__main__":
       __a          =		argparse.ArgumentParser()
       # Required parameters
       parser.add_argument(
           "--checkpoint_url",
           default="https://github.com/dandelin/ViLT/releases/download/200k/vilt_200k_mlm_itm.ckpt",
           type=str,
           help="URL of the checkpoint you\'d like to convert.",
       )
       parser.add_argument(
           "--pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model directory."
       )

       __a          =		parser.parse_args()
       convert_vilt_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path)








'''simple docstring'''







import argparse
from pathlib import Path
from typing import Dict, OrderedDict, Tuple

import torch
from audiocraft.models import MusicGen

from transformers import (
    AutoFeatureExtractor,
    AutoTokenizer,
    EncodecModel,
    MusicgenDecoderConfig,
    MusicgenForConditionalGeneration,
    MusicgenProcessor,
    TaEncoderModel,
)
from transformers.models.musicgen.modeling_musicgen import MusicgenForCausalLM
from transformers.utils import logging


logging.set_verbosity_info()
_A	:			List[Any]         =logging.get_logger(__name__)


_A	:			Dict         =['''model.decoder.embed_positions.weights''']





def  SCREAMING_SNAKE_CASE_       (UpperCamelCase      )      ->       str:
							if "emb" in name:
														lowerCamelCase__					:	Dict         =       name.replace("""emb"""				,			"""model.decoder.embed_tokens"""      )
							if "transformer" in name:
														lowerCamelCase__					:	List[str]         =       name.replace("""transformer"""				,			"""model.decoder"""      )
							if "cross_attention" in name:
														lowerCamelCase__					:	List[str]         =       name.replace("""cross_attention"""				,			"""encoder_attn"""      )
							if "linear1" in name:
														lowerCamelCase__					:	Optional[int]         =       name.replace("""linear1"""				,			"""fc1"""      )
							if "linear2" in name:
														lowerCamelCase__					:	Union[str, Any]         =       name.replace("""linear2"""				,			"""fc2"""      )
							if "norm1" in name:
														lowerCamelCase__					:	Dict         =       name.replace("""norm1"""				,			"""self_attn_layer_norm"""      )
							if "norm_cross" in name:
														lowerCamelCase__					:	Optional[Any]         =       name.replace("""norm_cross"""				,			"""encoder_attn_layer_norm"""      )
							if "norm2" in name:
														lowerCamelCase__					:	Dict         =       name.replace("""norm2"""				,			"""final_layer_norm"""      )
							if "out_norm" in name:
														lowerCamelCase__					:	Optional[Any]         =       name.replace("""out_norm"""				,			"""model.decoder.layer_norm"""      )
							if "linears" in name:
														lowerCamelCase__					:	Optional[Any]         =       name.replace("""linears"""				,			"""lm_heads"""      )
							if "condition_provider.conditioners.description.output_proj" in name:
														lowerCamelCase__					:	int         =       name.replace("""condition_provider.conditioners.description.output_proj"""				,			"""enc_to_dec_proj"""      )
							return name





def  SCREAMING_SNAKE_CASE_       (UpperCamelCase				,			UpperCamelCase      )      ->       Tuple[Dict, Dict]:
							lowerCamelCase__					:	int         =       list(state_dict.keys()      )
							lowerCamelCase__					:	Tuple         =       {}
							for key in keys:
														lowerCamelCase__					:	Any         =       state_dict.pop(UpperCamelCase      )
														lowerCamelCase__					:	Union[str, Any]         =       rename_keys(UpperCamelCase      )
														if "in_proj_weight" in key:
																					# split fused qkv proj
																					lowerCamelCase__					:	Union[str, Any]         =       val[:hidden_size, :]
																					lowerCamelCase__					:	Any         =       val[hidden_size : 2 * hidden_size, :]
																					lowerCamelCase__					:	Optional[int]         =       val[-hidden_size:, :]
														elif "enc_to_dec_proj" in key:
																					lowerCamelCase__					:	str         =       val
														else:
																					lowerCamelCase__					:	Union[str, Any]         =       val
							return state_dict, enc_dec_proj_state_dict





def  SCREAMING_SNAKE_CASE_       (UpperCamelCase      )      ->       MusicgenDecoderConfig:
							if checkpoint == "small":
														# default config values
														lowerCamelCase__					:	int         =       1024
														lowerCamelCase__					:	int         =       24
														lowerCamelCase__					:	List[Any]         =       16
							elif checkpoint == "medium":
														lowerCamelCase__					:	Any         =       1536
														lowerCamelCase__					:	Union[str, Any]         =       48
														lowerCamelCase__					:	Optional[int]         =       24
							elif checkpoint == "large":
														lowerCamelCase__					:	Optional[Any]         =       2048
														lowerCamelCase__					:	Dict         =       48
														lowerCamelCase__					:	List[Any]         =       32
							else:
														raise ValueError(f'''Checkpoint should be one of `[\'small\', \'medium\', \'large\']`, got {checkpoint}.'''      )
							lowerCamelCase__					:	Any         =       MusicgenDecoderConfig(
							    hidden_size=UpperCamelCase				,			ffn_dim=hidden_size * 4				,			num_hidden_layers=UpperCamelCase				,			num_attention_heads=UpperCamelCase				,			)
							return config





@torch.no_grad()
def  SCREAMING_SNAKE_CASE_       (UpperCamelCase				,			UpperCamelCase=None				,			UpperCamelCase=None				,			UpperCamelCase="cpu"      )      ->       Optional[Any]:
							lowerCamelCase__					:	Optional[int]         =       MusicGen.get_pretrained(UpperCamelCase				,			device=UpperCamelCase      )
							lowerCamelCase__					:	List[Any]         =       decoder_config_from_checkpoint(UpperCamelCase      )

							lowerCamelCase__					:	Any         =       fairseq_model.lm.state_dict()
							lowerCamelCase__  ,		lowerCamelCase__					:	Optional[int]         =       rename_state_dict(
							    UpperCamelCase				,			hidden_size=decoder_config.hidden_size      )

							lowerCamelCase__					:	str         =       TaEncoderModel.from_pretrained("""t5-base"""      )
							lowerCamelCase__					:	Tuple         =       EncodecModel.from_pretrained("""facebook/encodec_32khz"""      )
							lowerCamelCase__					:	Optional[int]         =       MusicgenForCausalLM(UpperCamelCase      ).eval()

							# load all decoder weights - expect that we'll be missing embeddings and enc-dec projection
							lowerCamelCase__  ,		lowerCamelCase__					:	List[str]         =       decoder.load_state_dict(UpperCamelCase				,			strict=UpperCamelCase      )

							for key in missing_keys.copy():
														if key.startswith(("""text_encoder""", """audio_encoder""")      ) or key in EXPECTED_MISSING_KEYS:
																					missing_keys.remove(UpperCamelCase      )

							if len(UpperCamelCase      ) > 0:
														raise ValueError(f'''Missing key(s) in state_dict: {missing_keys}'''      )

							if len(UpperCamelCase      ) > 0:
														raise ValueError(f'''Unexpected key(s) in state_dict: {unexpected_keys}'''      )

							# init the composite model
							lowerCamelCase__					:	Optional[Any]         =       MusicgenForConditionalGeneration(text_encoder=UpperCamelCase				,			audio_encoder=UpperCamelCase				,			decoder=UpperCamelCase      )

							# load the pre-trained enc-dec projection (from the decoder state dict)
							model.enc_to_dec_proj.load_state_dict(UpperCamelCase      )

							# check we can do a forward pass
							lowerCamelCase__					:	Dict         =       torch.arange(0				,			8				,			dtype=torch.long      ).reshape(2				,			-1      )
							lowerCamelCase__					:	Optional[Any]         =       input_ids.reshape(2 * 4				,			-1      )

							with torch.no_grad():
														lowerCamelCase__					:	Union[str, Any]         =       model(input_ids=UpperCamelCase				,			decoder_input_ids=UpperCamelCase      ).logits

							if logits.shape != (8, 1, 2048):
														raise ValueError("""Incorrect shape for logits"""      )

							# now construct the processor
							lowerCamelCase__					:	str         =       AutoTokenizer.from_pretrained("""t5-base"""      )
							lowerCamelCase__					:	Union[str, Any]         =       AutoFeatureExtractor.from_pretrained("""facebook/encodec_32khz"""				,			padding_side="""left"""      )

							lowerCamelCase__					:	Optional[int]         =       MusicgenProcessor(feature_extractor=UpperCamelCase				,			tokenizer=UpperCamelCase      )

							# set the appropriate bos/pad token ids
							lowerCamelCase__					:	Union[str, Any]         =       2048
							lowerCamelCase__					:	List[str]         =       2048

							# set other default generation config params
							lowerCamelCase__					:	Optional[Any]         =       int(30 * audio_encoder.config.frame_rate      )
							lowerCamelCase__					:	Union[str, Any]         =       True
							lowerCamelCase__					:	List[Any]         =       3.0

							if pytorch_dump_folder is not None:
														Path(UpperCamelCase      ).mkdir(exist_ok=UpperCamelCase      )
														logger.info(f'''Saving model {checkpoint} to {pytorch_dump_folder}'''      )
														model.save_pretrained(UpperCamelCase      )
														processor.save_pretrained(UpperCamelCase      )

							if repo_id:
														logger.info(f'''Pushing model {checkpoint} to {repo_id}'''      )
														model.push_to_hub(UpperCamelCase      )
														processor.push_to_hub(UpperCamelCase      )


if __name__ == "__main__":
			_A	:			Dict         =argparse.ArgumentParser()
			# Required parameters
			parser.add_argument(
			    '''--checkpoint''',
			    default='''small''',
			    type=str,
			    help='''Checkpoint size of the MusicGen model you\'d like to convert. Can be one of: `[\'small\', \'medium\', \'large\']`.''',
			)
			parser.add_argument(
			    '''--pytorch_dump_folder''',
			    required=True,
			    default=None,
			    type=str,
			    help='''Path to the output PyTorch model directory.''',
			)
			parser.add_argument(
			    '''--push_to_hub''', default=None, type=str, help='''Where to upload the converted model on the 🤗 hub.'''
			)
			parser.add_argument(
			    '''--device''', default='''cpu''', type=str, help='''Torch device to run the conversion, either cpu or cuda.'''
			)

			_A	:			List[str]         =parser.parse_args()
			convert_musicgen_checkpoint(args.checkpoint, args.pytorch_dump_folder, args.push_to_hub)

