



'''simple docstring'''
def A__   (					UpperCAmelCase_							):

						# bit count represents no. of bits in the gray code
						if bit_count < 0:
												raise ValueError('The given input must be positive'							)

						# get the generated string sequence
						_UpperCamelCase :		int			    =       gray_code_sequence_string(UpperCAmelCase_							)
						#
						# convert them to integers
						for i in range(len(UpperCAmelCase_							)							):
												_UpperCamelCase :		Any			    =       int(sequence[i]  ,  2							)

						return sequence






def A__   (					UpperCAmelCase_							):

						# The approach is a recursive one
						# Base case achieved when either n = 0 or n=1
						if bit_count == 0:
												return ["0"]

						if bit_count == 1:
												return ["0", "1"]

						_UpperCamelCase :		Optional[Any]			    =       1 << bit_count  # defines the length of the sequence
						# 1<< n is equivalent to 2^n

						# recursive answer will generate answer for n-1 bits
						_UpperCamelCase :		Union[str, Any]			    =       gray_code_sequence_string(bit_count - 1							)

						_UpperCamelCase :		List[Any]			    =       []

						# append 0 to first half of the smaller sequence generated
						for i in range(seq_len // 2							):
												_UpperCamelCase :		Union[str, Any]			    =       '0' + smaller_sequence[i]
												sequence.append(UpperCAmelCase_							)

						# append 1 to second half ... start from the end of the list
						for i in reversed(range(seq_len // 2							)							):
												_UpperCamelCase :		Dict			    =       '1' + smaller_sequence[i]
												sequence.append(UpperCAmelCase_							)

						return sequence


if __name__ == "__main__":
					import doctest

					doctest.testmod()





'''simple docstring'''
import argparse

import torch

from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert
from transformers.utils import logging


logging.set_verbosity_info()






def A__   (					UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_							):
						# Initialise PyTorch model
						_UpperCamelCase :		Any			    =       LxmertConfig.from_json_file(UpperCAmelCase_							)
						print(f'Building PyTorch model from configuration: {config}'							)
						_UpperCamelCase :		int			    =       LxmertForPreTraining(UpperCAmelCase_							)

						# Load weights from tf checkpoint
						load_tf_weights_in_lxmert(UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_							)

						# Save pytorch-model
						print(f'Save PyTorch model to {pytorch_dump_path}'							)
						torch.save(model.state_dict()  ,  UpperCAmelCase_							)


if __name__ == "__main__":
					snake_case_			:     int  	=  argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
					)
					parser.add_argument(
					    '--config_file',
					    default=None,
					    type=str,
					    required=True,
					    help='The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.',
					)
					parser.add_argument(
					    '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
					)
					snake_case_			:     List[str]  	=  parser.parse_args()
					convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)


