
def  __snake_case							(	__magic_name__		,    __magic_name__						):







				'''simple docstring'''


				lowercase         =      0
				lowercase         =      len(_A						) - 1

				while left <= right:
								# avoid divided by 0 during interpolation
								if sorted_collection[left] == sorted_collection[right]:
												if sorted_collection[left] == item:
																return left
												else:
																return None

								lowercase         =      left + ((item - sorted_collection[left]) * (right - left)) // (
								    sorted_collection[right] - sorted_collection[left]
								)

								# out of range check
								if point < 0 or point >= len(_A						):
												return None

								lowercase         =      sorted_collection[point]
								if current_item == item:
												return point
								else:
												if point < left:
																lowercase         =      left
																lowercase         =      point
												elif point > right:
																lowercase         =      right
																lowercase         =      point
												else:
																if item < current_item:
																				lowercase         =      point - 1
																else:
																				lowercase         =      point + 1
				return None

def  __snake_case							(	__magic_name__		,    __magic_name__		,    __magic_name__		,    __magic_name__						):







				'''simple docstring'''


				if sorted_collection[left] == sorted_collection[right]:
								if sorted_collection[left] == item:
												return left
								else:
												return None

				lowercase         =      left + ((item - sorted_collection[left]) * (right - left)) // (
				    sorted_collection[right] - sorted_collection[left]
				)

				# out of range check
				if point < 0 or point >= len(_A						):
								return None

				if sorted_collection[point] == item:
								return point
				elif point < left:
								return interpolation_search_by_recursion(_A		,    _A		,    _A		,    _A						)
				elif point > right:
								return interpolation_search_by_recursion(_A		,    _A		,    _A		,    _A						)
				else:
								if sorted_collection[point] > item:
												return interpolation_search_by_recursion(
												    _A		,    _A		,    _A		,    point - 1						)
								else:
												return interpolation_search_by_recursion(
												    _A		,    _A		,    point + 1		,    _A						)

def  __snake_case							(	__magic_name__						):







				'''simple docstring'''


				if collection != sorted(_A						):
								raise ValueError("Collection must be ascending sorted"						)
				return True


if __name__ == "__main__":
						import sys
						_snake_case      :							Optional[Any]     	=    0
						if debug == 1:
												_snake_case      :							Union[str, Any]     	=    [10, 30, 40, 45, 50, 66, 77, 93]
												try:
																		__assert_sorted(collection)
												except ValueError:
																		sys.exit("Sequence must be ascending sorted to apply interpolation search")
												_snake_case      :							str     	=    67

						_snake_case      :							Optional[Any]     	=    interpolation_search(collection, target)
						if result is not None:
												print(F"{target} found at positions: {result}")
						else:
												print("Not found")






import argparse

import torch

from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert
from transformers.utils import logging


logging.set_verbosity_info()


def 		lowerCamelCase__       (						_A	,      _A	,      _A				):







	'''simple docstring'''





	snake_case_						       =	MobileBertConfig.from_json_file(_A				)
	print(f"Building PyTorch model from configuration: {config}"				)
	snake_case_						       =	MobileBertForPreTraining(_A				)
	# Load weights from tf checkpoint
	snake_case_						       =	load_tf_weights_in_mobilebert(_A	,      _A	,      _A				)
	# Save pytorch-model
	print(f"Save PyTorch model to {pytorch_dump_path}"				)
	torch.save(model.state_dict()	,      _A				)


if __name__ == "__main__":
		lowercase__							:	Dict											=		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(
		    "--mobilebert_config_file",
		    default=None,
		    type=str,
		    required=True,
		    help=(
		        "The config json file corresponding to the pre-trained MobileBERT model. \n"
		        "This specifies the model architecture."
		    ),
		)
		parser.add_argument(
		    "--pytorch_dump_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
		)
		lowercase__							:	Tuple											=		parser.parse_args()
		convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.mobilebert_config_file, args.pytorch_dump_path)
