


import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch

   from transformers import MaskFormerForInstanceSegmentation, MaskFormerModel

   if is_vision_available():
      from transformers import MaskFormerImageProcessor

if is_vision_available():
   from PIL import Image





class 						__SCREAMING_SNAKE_CASE					:






     def __init__(			self     ,							__UpperCamelCase     ,							__UpperCamelCase=2     ,							__UpperCamelCase=True     ,							__UpperCamelCase=False     ,							__UpperCamelCase=10     ,							__UpperCamelCase=3     ,							__UpperCamelCase=32 * 4     ,							__UpperCamelCase=32 * 6     ,							__UpperCamelCase=4     ,							__UpperCamelCase=32     ,							)       ->    Any:
          _a						=		parent
          _a						=		batch_size
          _a						=		is_training
          _a						=		use_auxiliary_loss
          _a						=		num_queries
          _a						=		num_channels
          _a						=		min_size
          _a						=		max_size
          _a						=		num_labels
          _a						=		mask_feature_size






     def  a_					(			self		)       ->    Dict:
          _a						=		floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]		).to(
              __UpperCamelCase		)

          _a						=		torch.ones([self.batch_size, self.min_size, self.max_size]     ,							device=__UpperCamelCase		)

          _a						=		(
              torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]     ,							device=__UpperCamelCase		) > 0.5
          ).float()
          _a						=		(torch.rand((self.batch_size, self.num_labels)     ,							device=__UpperCamelCase		) > 0.5).long()

          _a						=		self.get_config()
          return config, pixel_values, pixel_mask, mask_labels, class_labels






     def  a_					(			self		)       ->    Any:
          return MaskFormerConfig.from_backbone_and_decoder_configs(
              backbone_config=SwinConfig(
                  depths=[1, 1, 1, 1]     ,							)     ,							decoder_config=DetrConfig(
                  decoder_ffn_dim=128     ,							num_queries=self.num_queries     ,							decoder_attention_heads=2     ,							d_model=self.mask_feature_size     ,							)     ,							mask_feature_size=self.mask_feature_size     ,							fpn_feature_size=self.mask_feature_size     ,							num_channels=self.num_channels     ,							num_labels=self.num_labels     ,							)






     def  a_					(			self		)       ->    List[Any]:
          _a						=		self.prepare_config_and_inputs()
          _a						=		{'''pixel_values''': pixel_values, '''pixel_mask''': pixel_mask}
          return config, inputs_dict






     def  a_					(			self     ,							__UpperCamelCase     ,							__UpperCamelCase		)       ->    List[str]:
          _a						=		output.encoder_hidden_states
          _a						=		output.pixel_decoder_hidden_states
          _a						=		output.transformer_decoder_hidden_states

          self.parent.assertTrue(len(__UpperCamelCase		)     ,							len(config.backbone_config.depths		)		)
          self.parent.assertTrue(len(__UpperCamelCase		)     ,							len(config.backbone_config.depths		)		)
          self.parent.assertTrue(len(__UpperCamelCase		)     ,							config.decoder_config.decoder_layers		)






     def  a_					(			self     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							__UpperCamelCase=False		)       ->    Optional[Any]:
          with torch.no_grad():
               _a						=		MaskFormerModel(config=__UpperCamelCase		)
               model.to(__UpperCamelCase		)
               model.eval()

               _a						=		model(pixel_values=__UpperCamelCase     ,							pixel_mask=__UpperCamelCase		)
               _a						=		model(__UpperCamelCase     ,							output_hidden_states=__UpperCamelCase		)
          # the correct shape of output.transformer_decoder_hidden_states ensure the correcteness of the
          # encoder and pixel decoder
          self.parent.assertEqual(
              output.transformer_decoder_last_hidden_state.shape     ,							(self.batch_size, self.num_queries, self.mask_feature_size)     ,							)
          # let's ensure the other two hidden state exists
          self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None		)
          self.parent.assertTrue(output.encoder_last_hidden_state is not None		)

          if output_hidden_states:
               self.check_output_hidden_state(__UpperCamelCase     ,							__UpperCamelCase		)






     def  a_					(			self     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							__UpperCamelCase		)       ->    List[Any]:
          _a						=		MaskFormerForInstanceSegmentation(config=__UpperCamelCase		)
          model.to(__UpperCamelCase		)
          model.eval()

          def comm_check_on_output(__UpperCamelCase		):
               # let's still check that all the required stuff is there
               self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None		)
               self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None		)
               self.parent.assertTrue(result.encoder_last_hidden_state is not None		)
               # okay, now we need to check the logits shape
               # due to the encoder compression, masks have a //4 spatial size
               self.parent.assertEqual(
                   result.masks_queries_logits.shape     ,							(self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)     ,							)
               # + 1 for null class
               self.parent.assertEqual(
                   result.class_queries_logits.shape     ,							(self.batch_size, self.num_queries, self.num_labels + 1)		)

          with torch.no_grad():
               _a						=		model(pixel_values=__UpperCamelCase     ,							pixel_mask=__UpperCamelCase		)
               _a						=		model(__UpperCamelCase		)

               comm_check_on_output(__UpperCamelCase		)

               _a						=		model(
                   pixel_values=__UpperCamelCase     ,							pixel_mask=__UpperCamelCase     ,							mask_labels=__UpperCamelCase     ,							class_labels=__UpperCamelCase		)

          comm_check_on_output(__UpperCamelCase		)

          self.parent.assertTrue(result.loss is not None		)
          self.parent.assertEqual(result.loss.shape     ,							torch.Size([1]		)		)







@require_torch
class 						__SCREAMING_SNAKE_CASE					(      UpperCamelCase_ ,			UpperCamelCase_ ,			unittest.TestCase ):
     UpperCAmelCase 					=				(MaskFormerModel, MaskFormerForInstanceSegmentation) if is_torch_available() else ()
     UpperCAmelCase 					=				(
         {'''feature-extraction''': MaskFormerModel, '''image-segmentation''': MaskFormerForInstanceSegmentation}
         if is_torch_available()
         else {}
     )

     UpperCAmelCase 					=				False
     UpperCAmelCase 					=				False
     UpperCAmelCase 					=				False
     UpperCAmelCase 					=				False






     def  a_					(			self		)       ->    List[str]:
          _a						=		MaskFormerModelTester(self		)
          _a						=		ConfigTester(self     ,							config_class=__UpperCamelCase     ,							has_text_modality=__UpperCamelCase		)






     def  a_					(			self		)       ->    List[Any]:
          self.config_tester.run_common_tests()






     def  a_					(			self		)       ->    List[str]:
          _a						=		self.model_tester.prepare_config_and_inputs_for_common()
          self.model_tester.create_and_check_maskformer_model(__UpperCamelCase     ,							**__UpperCamelCase     ,							output_hidden_states=__UpperCamelCase		)






     def  a_					(			self		)       ->    List[Any]:
          _a						=		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_maskformer_instance_segmentation_head_model(*__UpperCamelCase		)






     @unittest.skip(reason="MaskFormer does not use inputs_embeds"		)
     def  a_					(			self		)       ->    Optional[int]:
          pass






     @unittest.skip(reason="MaskFormer does not have a get_input_embeddings method"		)
     def  a_					(			self		)       ->    Union[str, Any]:
          pass






     @unittest.skip(reason="MaskFormer is not a generative model"		)
     def  a_					(			self		)       ->    int:
          pass






     @unittest.skip(reason="MaskFormer does not use token embeddings"		)
     def  a_					(			self		)       ->    Optional[Any]:
          pass






     @require_torch_multi_gpu
     @unittest.skip(
         reason="MaskFormer has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`"		)
     def  a_					(			self		)       ->    Dict:
          pass






     @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."		)
     def  a_					(			self		)       ->    Optional[int]:
          pass






     def  a_					(			self		)       ->    Optional[Any]:
          _a						=		self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
               _a						=		model_class(__UpperCamelCase		)
               _a						=		inspect.signature(model.forward		)
               # signature.parameters is an OrderedDict => so arg_names order is deterministic
               _a						=		[*signature.parameters.keys()]

               _a						=		['''pixel_values''']
               self.assertListEqual(arg_names[:1]     ,							__UpperCamelCase		)






     @slow
     def  a_					(			self		)       ->    List[Any]:
          for model_name in ["facebook/maskformer-swin-small-coco"]:
               _a						=		MaskFormerModel.from_pretrained(__UpperCamelCase		)
               self.assertIsNotNone(__UpperCamelCase		)






     def  a_					(			self		)       ->    Optional[Any]:
          _a						=		(self.model_tester.min_size,) * 2
          _a						=		{
              '''pixel_values''': torch.randn((2, 3, *size)     ,							device=__UpperCamelCase		),
              '''mask_labels''': torch.randn((2, 10, *size)     ,							device=__UpperCamelCase		),
              '''class_labels''': torch.zeros(2     ,							10     ,							device=__UpperCamelCase		).long(),
          }

          _a						=		MaskFormerForInstanceSegmentation(MaskFormerConfig()		).to(__UpperCamelCase		)
          _a						=		model(**__UpperCamelCase		)
          self.assertTrue(outputs.loss is not None		)






     def  a_					(			self		)       ->    Optional[int]:
          _a						=		self.model_tester.prepare_config_and_inputs_for_common()
          self.model_tester.create_and_check_maskformer_model(__UpperCamelCase     ,							**__UpperCamelCase     ,							output_hidden_states=__UpperCamelCase		)






     def  a_					(			self		)       ->    List[Any]:
          _a						=		self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
               _a						=		model_class(__UpperCamelCase		).to(__UpperCamelCase		)
               _a						=		model(**__UpperCamelCase     ,							output_attentions=__UpperCamelCase		)
               self.assertTrue(outputs.attentions is not None		)






     def  a_					(			self		)       ->    List[str]:
          if not self.model_tester.is_training:
               return
          # only MaskFormerForInstanceSegmentation has the loss
          _a						=		self.all_model_classes[1]
          _a						=		self.model_tester.prepare_config_and_inputs()

          _a						=		model_class(__UpperCamelCase		)
          model.to(__UpperCamelCase		)
          model.train()

          _a						=		model(__UpperCamelCase     ,							mask_labels=__UpperCamelCase     ,							class_labels=__UpperCamelCase		).loss
          loss.backward()






     def  a_					(			self		)       ->    Optional[int]:
          # only MaskFormerForInstanceSegmentation has the loss
          _a						=		self.all_model_classes[1]
          _a						=		self.model_tester.prepare_config_and_inputs()
          _a						=		True
          _a						=		True

          _a						=		model_class(__UpperCamelCase		)
          model.to(__UpperCamelCase		)
          model.train()

          _a						=		model(__UpperCamelCase     ,							mask_labels=__UpperCamelCase     ,							class_labels=__UpperCamelCase		)

          _a						=		outputs.encoder_hidden_states[0]
          encoder_hidden_states.retain_grad()

          _a						=		outputs.pixel_decoder_hidden_states[0]
          pixel_decoder_hidden_states.retain_grad()
          # we requires_grad=True in inputs_embeds (line 2152), the original implementation don't
          _a						=		outputs.transformer_decoder_hidden_states[0]
          transformer_decoder_hidden_states.retain_grad()

          _a						=		outputs.attentions[0]
          attentions.retain_grad()

          outputs.loss.backward(retain_graph=__UpperCamelCase		)

          self.assertIsNotNone(encoder_hidden_states.grad		)
          self.assertIsNotNone(pixel_decoder_hidden_states.grad		)
          self.assertIsNotNone(transformer_decoder_hidden_states.grad		)
          self.assertIsNotNone(attentions.grad		)







lowercase__				     =		1e-4






def __UpperCamelCase   (			)      ->     Optional[Any]:







     '''simple docstring'''






     _a						=		Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"				)
     return image






@require_vision
@slow
class 						__SCREAMING_SNAKE_CASE					(      unittest.TestCase ):






     @cached_property
     def  a_					(			self		)       ->    List[Any]:
          return (
              MaskFormerImageProcessor.from_pretrained("facebook/maskformer-swin-small-coco"		)
              if is_vision_available()
              else None
          )






     def  a_					(			self		)       ->    Tuple:
          _a						=		MaskFormerModel.from_pretrained("facebook/maskformer-swin-small-coco"		).to(__UpperCamelCase		)
          _a						=		self.default_image_processor
          _a						=		prepare_img()
          _a						=		image_processor(__UpperCamelCase     ,							return_tensors="pt"		).to(__UpperCamelCase		)
          _a						=		inputs['''pixel_values'''].shape
          # check size is divisible by 32
          self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0		)
          # check size
          self.assertEqual(__UpperCamelCase     ,							(1, 3, 800, 1_088)		)

          with torch.no_grad():
               _a						=		model(**__UpperCamelCase		)

          _a						=		torch.tensor(
              [[-0.04_82, 0.92_28, 0.49_51], [-0.25_47, 0.80_17, 0.85_27], [-0.00_69, 0.33_85, -0.00_89]]		).to(__UpperCamelCase		)
          self.assertTrue(
              torch.allclose(
                  outputs.encoder_last_hidden_state[0, 0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)

          _a						=		torch.tensor(
              [[-0.84_22, -0.84_34, -0.97_18], [-1.01_44, -0.55_65, -0.41_95], [-1.00_38, -0.44_84, -0.19_61]]		).to(__UpperCamelCase		)
          self.assertTrue(
              torch.allclose(
                  outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)

          _a						=		torch.tensor(
              [[0.28_52, -0.01_59, 0.97_35], [0.62_54, 0.18_58, 0.85_29], [-0.06_80, -0.41_16, 1.84_13]]		).to(__UpperCamelCase		)
          self.assertTrue(
              torch.allclose(
                  outputs.transformer_decoder_last_hidden_state[0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)






     def  a_					(			self		)       ->    List[Any]:
          _a						=		(
              MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-small-coco"		)
              .to(__UpperCamelCase		)
              .eval()
          )
          _a						=		self.default_image_processor
          _a						=		prepare_img()
          _a						=		image_processor(__UpperCamelCase     ,							return_tensors="pt"		).to(__UpperCamelCase		)
          _a						=		inputs['''pixel_values'''].shape
          # check size is divisible by 32
          self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0		)
          # check size
          self.assertEqual(__UpperCamelCase     ,							(1, 3, 800, 1_088)		)

          with torch.no_grad():
               _a						=		model(**__UpperCamelCase		)
          # masks_queries_logits
          _a						=		outputs.masks_queries_logits
          self.assertEqual(
              masks_queries_logits.shape     ,							(1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)     ,							)
          _a						=		[
              [-1.3_73_71_24, -1.7_72_49_37, -1.9_36_42_33],
              [-1.5_97_72_81, -1.9_86_79_39, -2.1_52_36_95],
              [-1.5_79_53_98, -1.9_26_98_32, -2.09_39_42],
          ]
          _a						=		torch.tensor(__UpperCamelCase		).to(__UpperCamelCase		)
          self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)
          # class_queries_logits
          _a						=		outputs.class_queries_logits
          self.assertEqual(
              class_queries_logits.shape     ,							(1, model.config.decoder_config.num_queries, model.config.num_labels + 1)		)
          _a						=		torch.tensor(
              [
                  [1.65_12e00, -5.25_72e00, -3.35_19e00],
                  [3.61_69e-02, -5.90_25e00, -2.93_13e00],
                  [1.07_66e-04, -7.76_30e00, -5.12_63e00],
              ]		).to(__UpperCamelCase		)
          self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)






     def  a_					(			self		)       ->    Optional[Any]:
          _a						=		(
              MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-resnet101-coco-stuff"		)
              .to(__UpperCamelCase		)
              .eval()
          )
          _a						=		self.default_image_processor
          _a						=		prepare_img()
          _a						=		image_processor(__UpperCamelCase     ,							return_tensors="pt"		).to(__UpperCamelCase		)
          _a						=		inputs['''pixel_values'''].shape
          # check size is divisible by 32
          self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0		)
          # check size
          self.assertEqual(__UpperCamelCase     ,							(1, 3, 800, 1_088)		)

          with torch.no_grad():
               _a						=		model(**__UpperCamelCase		)
          # masks_queries_logits
          _a						=		outputs.masks_queries_logits
          self.assertEqual(
              masks_queries_logits.shape     ,							(1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)     ,							)
          _a						=		[[-0.90_46, -2.63_66, -4.60_62], [-3.41_79, -5.78_90, -8.80_57], [-4.91_79, -7.65_60, -10.77_11]]
          _a						=		torch.tensor(__UpperCamelCase		).to(__UpperCamelCase		)
          self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)
          # class_queries_logits
          _a						=		outputs.class_queries_logits
          self.assertEqual(
              class_queries_logits.shape     ,							(1, model.config.decoder_config.num_queries, model.config.num_labels + 1)		)
          _a						=		torch.tensor(
              [[4.71_88, -3.25_85, -2.88_57], [6.68_71, -2.91_81, -1.24_87], [7.24_49, -2.27_64, -2.18_74]]		).to(__UpperCamelCase		)
          self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]     ,							__UpperCamelCase     ,							atol=__UpperCamelCase		)		)






     def  a_					(			self		)       ->    str:
          _a						=		(
              MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-small-coco"		)
              .to(__UpperCamelCase		)
              .eval()
          )
          _a						=		self.default_image_processor

          _a						=		image_processor(
              [np.zeros((3, 800, 1_333)		), np.zeros((3, 800, 1_333)		)]     ,							segmentation_maps=[np.zeros((384, 384)		).astype(np.floataa		), np.zeros((384, 384)		).astype(np.floataa		)]     ,							return_tensors="pt"     ,							)

          _a						=		inputs['''pixel_values'''].to(__UpperCamelCase		)
          _a						=		[el.to(__UpperCamelCase		) for el in inputs['''mask_labels''']]
          _a						=		[el.to(__UpperCamelCase		) for el in inputs['''class_labels''']]

          with torch.no_grad():
               _a						=		model(**__UpperCamelCase		)

          self.assertTrue(outputs.loss is not None		)





'''simple docstring'''

import argparse
import os
import pickle
import sys

import torch

from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl
from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils
from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS_NAME, VOCAB_FILES_NAMES
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()

# We do this to be able to load python 2 datasets pickles
# See e.g. https://stackoverflow.com/questions/2121874/python-pickling-after-changing-a-modules-directory/2121918#2121918
lowercase__				     =		data_utils.TransfoXLTokenizer
lowercase__				     =		data_utils.TransfoXLCorpus
lowercase__				     =		data_utils
lowercase__				     =		data_utils






def __UpperCamelCase   (			__lowerCamelCase		: str      ,  __lowerCamelCase		: Tuple      ,  __lowerCamelCase		: Optional[int]      ,  __lowerCamelCase		: Tuple				)      ->     Dict:







     '''simple docstring'''






     if transfo_xl_dataset_file:
          # Convert a pre-processed corpus (see original TensorFlow repo)
          with open(__lowerCamelCase      ,  "rb"				) as fp:
               _a						=		pickle.load(__lowerCamelCase      ,  encoding="latin1"				)
          # Save vocabulary and dataset cache as Dictionaries (should be better than pickles for the long-term)
          _a						=		pytorch_dump_folder_path + "/" + VOCAB_FILES_NAMES["pretrained_vocab_file"]
          print(F"Save vocabulary to {pytorch_vocab_dump_path}"				)
          _a						=		corpus.vocab.__dict__
          torch.save(__lowerCamelCase      ,  __lowerCamelCase				)

          _a						=		corpus.__dict__
          corpus_dict_no_vocab.pop("vocab"      ,  __lowerCamelCase				)
          _a						=		pytorch_dump_folder_path + "/" + CORPUS_NAME
          print(F"Save dataset to {pytorch_dataset_dump_path}"				)
          torch.save(__lowerCamelCase      ,  __lowerCamelCase				)

     if tf_checkpoint_path:
          # Convert a pre-trained TensorFlow model
          _a						=		os.path.abspath(__lowerCamelCase				)
          _a						=		os.path.abspath(__lowerCamelCase				)

          print(F"Converting Transformer XL checkpoint from {tf_path} with config at {config_path}."				)
          # Initialise PyTorch model
          if transfo_xl_config_file == "":
               _a						=		TransfoXLConfig()
          else:
               _a						=		TransfoXLConfig.from_json_file(__lowerCamelCase				)
          print(F"Building PyTorch model from configuration: {config}"				)
          _a						=		TransfoXLLMHeadModel(__lowerCamelCase				)

          _a						=		load_tf_weights_in_transfo_xl(__lowerCamelCase      ,  __lowerCamelCase      ,  __lowerCamelCase				)
          # Save pytorch-model
          _a						=		os.path.join(__lowerCamelCase      ,  __lowerCamelCase				)
          _a						=		os.path.join(__lowerCamelCase      ,  __lowerCamelCase				)
          print(F"Save PyTorch model to {os.path.abspath(__lowerCamelCase				)}"				)
          torch.save(model.state_dict()      ,  __lowerCamelCase				)
          print(F"Save configuration file to {os.path.abspath(__lowerCamelCase				)}"				)
          with open(__lowerCamelCase      ,  "w"      ,  encoding="utf-8"				) as f:
               f.write(config.to_json_string()				)


if __name__ == "__main__":
   lowercase__				     =		argparse.ArgumentParser()
   parser.add_argument(
       "--pytorch_dump_folder_path",
       default=None,
       type=str,
       required=True,
       help="Path to the folder to store the PyTorch model or dataset/vocab.",
   )
   parser.add_argument(
       "--tf_checkpoint_path",
       default="",
       type=str,
       help="An optional path to a TensorFlow checkpoint path to be converted.",
   )
   parser.add_argument(
       "--transfo_xl_config_file",
       default="",
       type=str,
       help=(
           "An optional config json file corresponding to the pre-trained BERT model. \n"
           "This specifies the model architecture."
       ),
   )
   parser.add_argument(
       "--transfo_xl_dataset_file",
       default="",
       type=str,
       help="An optional dataset file to be converted in a vocabulary.",
   )
   lowercase__				     =		parser.parse_args()
   convert_transfo_xl_checkpoint_to_pytorch(
       args.tf_checkpoint_path,
       args.transfo_xl_config_file,
       args.pytorch_dump_folder_path,
       args.transfo_xl_dataset_file,
   )

