
import argparse

import torch

from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert
from transformers.utils import logging


logging.set_verbosity_info()



def      __lowerCAmelCase						(							UpperCAmelCase__				:      str			,				UpperCAmelCase__				:      str			,				UpperCAmelCase__				:      Optional[int]       )  ->    Tuple:
							# Initialise PyTorch model
							lowerCamelCase_							  =					RemBertConfig.from_json_file(UpperCAmelCase__       )
							print("""Building PyTorch model from configuration: {}""".format(str(UpperCAmelCase__       )       )       )
							lowerCamelCase_							  =					RemBertModel(UpperCAmelCase__       )

							# Load weights from tf checkpoint
							load_tf_weights_in_rembert(UpperCAmelCase__			,				UpperCAmelCase__			,				UpperCAmelCase__       )

							# Save pytorch-model
							print("""Save PyTorch model to {}""".format(UpperCAmelCase__       )       )
							torch.save(model.state_dict()			,				UpperCAmelCase__       )


if __name__ == "__main__":
		lowercase        =  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(
		    '''--rembert_config_file''',
		    default=None,
		    type=str,
		    required=True,
		    help=(
		        '''The config json file corresponding to the pre-trained RemBERT 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        =  parser.parse_args()
		convert_rembert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.rembert_config_file, args.pytorch_dump_path)







import numpy as np
from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
from sklearn.metrics import ConfusionMatrixDisplay
from sklearn.model_selection import train_test_split
from xgboost import XGBClassifier



def      __lowerCAmelCase						(							UpperCAmelCase__				:      dict       )  ->    tuple:
							return (data["data"], data["target"])



def      __lowerCAmelCase						(							UpperCAmelCase__				:      np.ndarray			,				UpperCAmelCase__				:      np.ndarray       )  ->    XGBClassifier:
							lowerCamelCase_							  =					XGBClassifier()
							classifier.fit(UpperCAmelCase__			,				UpperCAmelCase__       )
							return classifier



def      __lowerCAmelCase						(							)  ->    None:
							lowerCamelCase_							  =					load_iris()
							lowerCamelCase_  ,   lowerCamelCase_							  =					data_handling(UpperCAmelCase__       )
							lowerCamelCase_  ,   lowerCamelCase_  ,   lowerCamelCase_  ,   lowerCamelCase_							  =					train_test_split(
							    UpperCAmelCase__			,				UpperCAmelCase__			,				test_size=0.2_5       )

							lowerCamelCase_							  =					iris["""target_names"""]

							# Create an XGBoost Classifier from the training data
							lowerCamelCase_							  =					xgboost(UpperCAmelCase__			,				UpperCAmelCase__       )

							# Display the confusion matrix of the classifier with both training and test sets
							ConfusionMatrixDisplay.from_estimator(
							    UpperCAmelCase__			,				UpperCAmelCase__			,				UpperCAmelCase__			,				display_labels=UpperCAmelCase__			,				cmap="""Blues"""			,				normalize="""true"""			,				)
							plt.title("""Normalized Confusion Matrix - IRIS Dataset"""       )
							plt.show()


if __name__ == "__main__":
		import doctest

		doctest.testmod(verbose=True)
		main()





