






'''simple docstring'''

import tempfile
import unittest

import numpy as np

import transformers
from transformers import GPTaConfig, GPTaTokenizer, is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow

from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
						import jax
						import jax.numpy as jnp

						from transformers.modeling_flax_pytorch_utils import (
						    convert_pytorch_state_dict_to_flax,
						    load_flax_weights_in_pytorch_model,
						)
						from transformers.models.gpta.modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel

if is_torch_available():
						import torch






class 				__magic_name__  :







	"""simple docstring"""



	def __init__(				self	,   _lowercase	,   _lowercase=14	,   _lowercase=7	,   _lowercase=True	,   _lowercase=True	,   _lowercase=False	,   _lowercase=True	,   _lowercase=99	,   _lowercase=32	,   _lowercase=5	,   _lowercase=4	,   _lowercase=37	,   _lowercase="gelu"	,   _lowercase=0.1	,   _lowercase=0.1	,   _lowercase=512	,   _lowercase=0.02	,   )    ->	Dict:
							lowercase_   : Tuple   	=      parent
							lowercase_   : str   	=      batch_size
							lowercase_   : Dict   	=      seq_length
							lowercase_   : Optional[Any]   	=      is_training
							lowercase_   : str   	=      use_input_mask
							lowercase_   : Optional[Any]   	=      use_token_type_ids
							lowercase_   : Dict   	=      use_labels
							lowercase_   : Tuple   	=      vocab_size
							lowercase_   : str   	=      hidden_size
							lowercase_   : List[Any]   	=      num_hidden_layers
							lowercase_   : List[str]   	=      num_attention_heads
							lowercase_   : Optional[int]   	=      intermediate_size
							lowercase_   : Tuple   	=      hidden_act
							lowercase_   : List[Any]   	=      hidden_dropout_prob
							lowercase_   : Dict   	=      attention_probs_dropout_prob
							lowercase_   : List[Any]   	=      max_position_embeddings
							lowercase_   : str   	=      initializer_range
							lowercase_   : List[str]   	=      None
							lowercase_   : Any   	=      vocab_size - 1
							lowercase_   : Any   	=      vocab_size - 1
							lowercase_   : Union[str, Any]   	=      vocab_size - 1
	def 							lowerCamelCase__		(				self							)    ->	Optional[Any]:
							lowercase_   : int   	=      ids_tensor([self.batch_size, self.seq_length]	,   self.vocab_size							)

							lowercase_   : Union[str, Any]   	=      None
							if self.use_input_mask:
													lowercase_   : Tuple   	=      random_attention_mask([self.batch_size, self.seq_length]							)

							lowercase_   : Tuple   	=      GPTaConfig(
							    vocab_size=self.vocab_size	,   n_embd=self.hidden_size	,   n_layer=self.num_hidden_layers	,   n_head=self.num_attention_heads	,   n_positions=self.max_position_embeddings	,   use_cache=_lowercase	,   bos_token_id=self.bos_token_id	,   eos_token_id=self.eos_token_id	,   pad_token_id=self.pad_token_id	,   )

							return (config, input_ids, input_mask)
	def 							lowerCamelCase__		(				self							)    ->	Tuple:
							lowercase_   : Union[str, Any]   	=      self.prepare_config_and_inputs()
							lowercase_	,   lowercase_	,   lowercase_   : Dict   	=      config_and_inputs
							lowercase_   : Optional[Any]   	=      {'input_ids': input_ids, 'attention_mask': attention_mask}
							return config, inputs_dict
	def 							lowerCamelCase__		(				self							)    ->	int:
							lowercase_	,   lowercase_	,   lowercase_   : Union[str, Any]   	=      self.prepare_config_and_inputs()

							lowercase_   : Optional[int]   	=      floats_tensor([self.batch_size, self.seq_length, self.hidden_size]							)
							lowercase_   : str   	=      ids_tensor([self.batch_size, self.seq_length]	,   vocab_size=2							)

							return (
							    config,
							    input_ids,
							    attention_mask,
							    encoder_hidden_states,
							    encoder_attention_mask,
							)
	def 							lowerCamelCase__		(				self	,   _lowercase	,   _lowercase	,   _lowercase	,   _lowercase							)    ->	int:
							lowercase_   : List[Any]   	=      20
							lowercase_   : str   	=      model_class_name(_lowercase							)

							lowercase_   : Union[str, Any]   	=      model.init_cache(input_ids.shape[0]	,   _lowercase							)
							lowercase_   : Optional[Any]   	=      jnp.ones((input_ids.shape[0], max_decoder_length)	,   dtype='i4'							)

							lowercase_   : Tuple   	=      jnp.broadcast_to(
							    jnp.arange(input_ids.shape[-1] - 1							)[None, :]	,   (input_ids.shape[0], input_ids.shape[-1] - 1)							)
							lowercase_   : List[Any]   	=      model(
							    input_ids[:, :-1]	,   attention_mask=_lowercase	,   past_key_values=_lowercase	,   position_ids=_lowercase	,   )

							lowercase_   : Optional[int]   	=      jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]	,   dtype='i4'							)
							lowercase_   : Union[str, Any]   	=      model(
							    input_ids[:, -1:]	,   attention_mask=_lowercase	,   past_key_values=outputs_cache.past_key_values	,   position_ids=_lowercase	,   )

							lowercase_   : str   	=      model(_lowercase							)

							lowercase_   : Dict   	=      np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])							)							)
							self.parent.assertTrue(diff < 1E-3	,   msg=f"Max diff is {diff}"							)







	def 							lowerCamelCase__		(				self	,   _lowercase	,   _lowercase	,   _lowercase	,   _lowercase							)    ->	Any:
							lowercase_   : str   	=      20
							lowercase_   : int   	=      model_class_name(_lowercase							)

							lowercase_   : Union[str, Any]   	=      jnp.concatenate(
							    [attention_mask, jnp.zeros((attention_mask.shape[0], max_decoder_length - attention_mask.shape[1])							)]	,   axis=-1	,   )

							lowercase_   : List[Any]   	=      model.init_cache(input_ids.shape[0]	,   _lowercase							)
							lowercase_   : List[Any]   	=      jnp.broadcast_to(
							    jnp.arange(input_ids.shape[-1] - 1							)[None, :]	,   (input_ids.shape[0], input_ids.shape[-1] - 1)							)

							lowercase_   : Optional[int]   	=      model(
							    input_ids[:, :-1]	,   attention_mask=_lowercase	,   past_key_values=_lowercase	,   position_ids=_lowercase	,   )
							lowercase_   : Any   	=      jnp.array(input_ids.shape[0] * [[input_ids.shape[-1] - 1]]	,   dtype='i4'							)
							lowercase_   : str   	=      model(
							    input_ids[:, -1:]	,   past_key_values=outputs_cache.past_key_values	,   attention_mask=_lowercase	,   position_ids=_lowercase	,   )

							lowercase_   : Any   	=      model(_lowercase	,   attention_mask=_lowercase							)

							lowercase_   : Tuple   	=      np.max(np.abs((outputs_cache_next[0][:, -1, :5] - outputs[0][:, -1, :5])							)							)
							self.parent.assertTrue(diff < 1E-3	,   msg=f"Max diff is {diff}"							)






@require_flax
class 				__magic_name__  (						UpperCAmelCase_,    UpperCAmelCase_,    unittest.TestCase					):







	"""simple docstring"""



	SCREAMING_SNAKE_CASE_       :   Optional[int]   =	(FlaxGPTaModel, FlaxGPTaLMHeadModel) if is_flax_available() else ()
	SCREAMING_SNAKE_CASE_       :   str   =	(FlaxGPTaLMHeadModel,) if is_flax_available() else ()
	def 							lowerCamelCase__		(				self							)    ->	Optional[int]:
							lowercase_   : Optional[Any]   	=      FlaxGPTaModelTester(self							)
	def 							lowerCamelCase__		(				self							)    ->	Union[str, Any]:
							for model_class_name in self.all_model_classes:
													lowercase_	,   lowercase_	,   lowercase_   : List[Any]   	=      self.model_tester.prepare_config_and_inputs()
													self.model_tester.check_use_cache_forward(_lowercase	,   _lowercase	,   _lowercase	,   _lowercase							)
	def 							lowerCamelCase__		(				self							)    ->	str:
							for model_class_name in self.all_model_classes:
													lowercase_	,   lowercase_	,   lowercase_   : Optional[Any]   	=      self.model_tester.prepare_config_and_inputs()
													self.model_tester.check_use_cache_forward_with_attn_mask(
													    _lowercase	,   _lowercase	,   _lowercase	,   _lowercase							)
	@slow
	def 							lowerCamelCase__		(				self							)    ->	str:
							lowercase_   : Dict   	=      GPTaTokenizer.from_pretrained('gpt2'	,   pad_token='</s>'	,   padding_side='left'							)
							lowercase_   : str   	=      tokenizer(['Hello this is a long string', 'Hey']	,   return_tensors='np'	,   padding=_lowercase	,   truncation=_lowercase							)

							lowercase_   : Any   	=      FlaxGPTaLMHeadModel.from_pretrained('gpt2'							)
							lowercase_   : Any   	=      False
							lowercase_   : int   	=      model.config.eos_token_id

							lowercase_   : Any   	=      jax.jit(model.generate							)

							lowercase_   : List[str]   	=      jit_generate(inputs['input_ids']	,   attention_mask=inputs['attention_mask']							).sequences

							lowercase_   : Any   	=      tokenizer.batch_decode(_lowercase	,   skip_special_tokens=_lowercase							)

							lowercase_   : Optional[int]   	=      [
							    'Hello this is a long string of words. I\'m going to start with the first one.\n',
							    'Hey, I\'m not sure if I\'m going to be able to do',
							]

							self.assertListEqual(_lowercase	,   _lowercase							)
	@is_pt_flax_cross_test
	def 							lowerCamelCase__		(				self							)    ->	List[Any]:
							lowercase_	,   lowercase_   : Optional[Any]   	=      self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
													with self.subTest(model_class.__name__							):
																			# prepare inputs
																			lowercase_   : Union[str, Any]   	=      self._prepare_for_class(_lowercase	,   _lowercase							)
																			lowercase_   : List[Any]   	=      {k: torch.tensor(v.tolist()							) for k, v in prepared_inputs_dict.items()}

																			# load corresponding PyTorch class
																			lowercase_   : str   	=      model_class.__name__[4:]  # Skip the "Flax" at the beginning
																			lowercase_   : List[Any]   	=      getattr(_lowercase	,   _lowercase							)

																			lowercase_	,   lowercase_   : List[str]   	=      pt_inputs['input_ids'].shape
																			lowercase_   : Optional[Any]   	=      np.random.randint(0	,   seq_length - 1	,   size=(batch_size,)							)
																			for batch_idx, start_index in enumerate(_lowercase							):
																									lowercase_   : List[str]   	=      0
																									lowercase_   : List[str]   	=      1
																									lowercase_   : List[Any]   	=      0
																									lowercase_   : Optional[int]   	=      1
																			lowercase_   : Dict   	=      pt_model_class(_lowercase							).eval()
																			lowercase_   : List[str]   	=      model_class(_lowercase	,   dtype=jnp.floataa							)

																			lowercase_   : List[Any]   	=      convert_pytorch_state_dict_to_flax(pt_model.state_dict()	,   _lowercase							)
																			lowercase_   : Optional[Any]   	=      fx_state

																			with torch.no_grad():
																									lowercase_   : Optional[Any]   	=      pt_model(**_lowercase							).to_tuple()

																			lowercase_   : List[str]   	=      fx_model(**_lowercase							).to_tuple()
																			self.assertEqual(len(_lowercase							)	,   len(_lowercase							)	,   'Output lengths differ between Flax and PyTorch'							)
																			for fx_output, pt_output in zip(_lowercase	,   _lowercase							):
																									self.assert_almost_equals(fx_output[:, -1]	,   pt_output[:, -1].numpy()	,   4E-2							)

																			with tempfile.TemporaryDirectory() as tmpdirname:
																									pt_model.save_pretrained(_lowercase							)
																									lowercase_   : Union[str, Any]   	=      model_class.from_pretrained(_lowercase	,   from_pt=_lowercase							)

																			lowercase_   : int   	=      fx_model_loaded(**_lowercase							).to_tuple()
																			self.assertEqual(
																			    len(_lowercase							)	,   len(_lowercase							)	,   'Output lengths differ between Flax and PyTorch'							)
																			for fx_output_loaded, pt_output in zip(_lowercase	,   _lowercase							):
																									self.assert_almost_equals(fx_output_loaded[:, -1]	,   pt_output[:, -1].numpy()	,   4E-2							)
	@is_pt_flax_cross_test
	def 							lowerCamelCase__		(				self							)    ->	Union[str, Any]:
							lowercase_	,   lowercase_   : Any   	=      self.model_tester.prepare_config_and_inputs_for_common()
							for model_class in self.all_model_classes:
													with self.subTest(model_class.__name__							):
																			# prepare inputs
																			lowercase_   : Any   	=      self._prepare_for_class(_lowercase	,   _lowercase							)
																			lowercase_   : Any   	=      {k: torch.tensor(v.tolist()							) for k, v in prepared_inputs_dict.items()}

																			# load corresponding PyTorch class
																			lowercase_   : Dict   	=      model_class.__name__[4:]  # Skip the "Flax" at the beginning
																			lowercase_   : Optional[Any]   	=      getattr(_lowercase	,   _lowercase							)

																			lowercase_   : Union[str, Any]   	=      pt_model_class(_lowercase							).eval()
																			lowercase_   : List[Any]   	=      model_class(_lowercase	,   dtype=jnp.floataa							)

																			lowercase_   : int   	=      load_flax_weights_in_pytorch_model(_lowercase	,   fx_model.params							)
																			lowercase_	,   lowercase_   : int   	=      pt_inputs['input_ids'].shape
																			lowercase_   : List[str]   	=      np.random.randint(0	,   seq_length - 1	,   size=(batch_size,)							)
																			for batch_idx, start_index in enumerate(_lowercase							):
																									lowercase_   : Tuple   	=      0
																									lowercase_   : Optional[int]   	=      1
																									lowercase_   : Optional[int]   	=      0
																									lowercase_   : List[str]   	=      1

																			# make sure weights are tied in PyTorch
																			pt_model.tie_weights()

																			with torch.no_grad():
																									lowercase_   : Tuple   	=      pt_model(**_lowercase							).to_tuple()

																			lowercase_   : Tuple   	=      fx_model(**_lowercase							).to_tuple()
																			self.assertEqual(len(_lowercase							)	,   len(_lowercase							)	,   'Output lengths differ between Flax and PyTorch'							)
																			for fx_output, pt_output in zip(_lowercase	,   _lowercase							):
																									self.assert_almost_equals(fx_output[:, -1]	,   pt_output[:, -1].numpy()	,   4E-2							)

																			with tempfile.TemporaryDirectory() as tmpdirname:
																									fx_model.save_pretrained(_lowercase							)
																									lowercase_   : int   	=      pt_model_class.from_pretrained(_lowercase	,   from_flax=_lowercase							)

																			with torch.no_grad():
																									lowercase_   : List[str]   	=      pt_model_loaded(**_lowercase							).to_tuple()

																			self.assertEqual(
																			    len(_lowercase							)	,   len(_lowercase							)	,   'Output lengths differ between Flax and PyTorch'							)
																			for fx_output, pt_output in zip(_lowercase	,   _lowercase							):
																									self.assert_almost_equals(fx_output[:, -1]	,   pt_output[:, -1].numpy()	,   4E-2							)







	@slow
	def 							lowerCamelCase__		(				self							)    ->	Union[str, Any]:
							for model_class_name in self.all_model_classes:
													lowercase_   : List[Any]   	=      model_class_name.from_pretrained('gpt2'	,   from_pt=_lowercase							)
													lowercase_   : Any   	=      model(np.ones((1, 1)							)							)
													self.assertIsNotNone(_lowercase							)








'''simple docstring'''

import subprocess
import sys
import warnings
from argparse import ArgumentParser
from pathlib import Path

from packaging import version

from .. import AutoFeatureExtractor, AutoImageProcessor, AutoProcessor, AutoTokenizer
from ..utils import logging
from ..utils.import_utils import is_optimum_available
from .convert import export, validate_model_outputs
from .features import FeaturesManager
from .utils import get_preprocessor


A:   List[str]						=					"1.5.0"

A:   Any						=					["vision-encoder-decoder"]






def 						_UpperCAmelCase     (	a		:						int				)      ->      List[str]:





						"""simple docstring"""
						if is_optimum_available():
												from optimum.version import __version__ as optimum_version

												lowercase_   : List[Any]   	=      version.parse(a				)
												if parsed_optimum_version < version.parse(a				):
																		raise RuntimeError(
																		    f"transformers.onnx requires optimum >= {MIN_OPTIMUM_VERSION} but {optimum_version} is installed. You "
																		    'can upgrade optimum by running: pip install -U optimum[exporters]'				)
						else:
												raise RuntimeError(
												    'transformers.onnx requires optimum to run, you can install the library by running: pip install '
												    'optimum[exporters]'				)
						lowercase_   : List[Any]   	=      [
						    sys.executable,
						    '-m',
						    'optimum.exporters.onnx',
						    f"--model {args.model}",
						    f"--task {args.feature}",
						    f"--framework {args.framework}" if args.framework is not None else '',
						    f"{args.output}",
						]
						lowercase_   : Tuple   	=      subprocess.Popen(' '.join(a				)    ,      stdout=subprocess.PIPE    ,      shell=a				)
						proc.wait()

						logger.info(
						    'The export was done by optimum.exporters.onnx. We recommend using to use this package directly in future, as '
						    'transformers.onnx is deprecated, and will be removed in v5. You can find more information here: '
						    'https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/export_a_model.'				)






def 						_UpperCAmelCase     (	a		:						Dict				)      ->      Optional[Any]:





						"""simple docstring"""
						lowercase_   : Optional[int]   	=      args.output if args.output.is_file() else args.output.joinpath('model.onnx'				)
						if not args.output.parent.exists():
												args.output.parent.mkdir(parents=a				)

						# Allocate the model
						lowercase_   : int   	=      FeaturesManager.get_model_from_feature(
						    args.feature    ,      args.model    ,      framework=args.framework    ,      cache_dir=args.cache_dir				)

						lowercase_	,   lowercase_   : List[Any]   	=      FeaturesManager.check_supported_model_or_raise(a    ,      feature=args.feature				)
						lowercase_   : List[str]   	=      model_onnx_config(model.config				)

						if model_kind in ENCODER_DECODER_MODELS:
												lowercase_   : List[Any]   	=      model.get_encoder()
												lowercase_   : Any   	=      model.get_decoder()

												lowercase_   : List[str]   	=      onnx_config.get_encoder_config(encoder_model.config				)
												lowercase_   : int   	=      onnx_config.get_decoder_config(
												    encoder_model.config    ,      decoder_model.config    ,      feature=args.feature				)

												if args.opset is None:
																		lowercase_   : int   	=      max(encoder_onnx_config.default_onnx_opset    ,      decoder_onnx_config.default_onnx_opset				)

												if args.opset < min(encoder_onnx_config.default_onnx_opset    ,      decoder_onnx_config.default_onnx_opset				):
																		raise ValueError(
																		    f"Opset {args.opset} is not sufficient to export {model_kind}. At least "
																		    f" {min(encoder_onnx_config.default_onnx_opset    ,      decoder_onnx_config.default_onnx_opset				)} is required."				)

												lowercase_   : str   	=      AutoFeatureExtractor.from_pretrained(args.model				)

												lowercase_	,   lowercase_   : str   	=      export(
												    a    ,      a    ,      a    ,      args.opset    ,      args.output.parent.joinpath('encoder_model.onnx'				)    ,      )

												validate_model_outputs(
												    a    ,      a    ,      a    ,      args.output.parent.joinpath('encoder_model.onnx'				)    ,      a    ,      args.atol if args.atol else encoder_onnx_config.atol_for_validation    ,      )

												lowercase_   : Optional[Any]   	=      AutoTokenizer.from_pretrained(args.model				)

												lowercase_	,   lowercase_   : Union[str, Any]   	=      export(
												    a    ,      a    ,      a    ,      args.opset    ,      args.output.parent.joinpath('decoder_model.onnx'				)    ,      )

												validate_model_outputs(
												    a    ,      a    ,      a    ,      args.output.parent.joinpath('decoder_model.onnx'				)    ,      a    ,      args.atol if args.atol else decoder_onnx_config.atol_for_validation    ,      )
												logger.info(
												    f"All good, model saved at: {args.output.parent.joinpath('encoder_model.onnx'				).as_posix()},"
												    f" {args.output.parent.joinpath('decoder_model.onnx'				).as_posix()}"				)

						else:
												# Instantiate the appropriate preprocessor
												if args.preprocessor == "auto":
																		lowercase_   : List[Any]   	=      get_preprocessor(args.model				)
												elif args.preprocessor == "tokenizer":
																		lowercase_   : List[str]   	=      AutoTokenizer.from_pretrained(args.model				)
												elif args.preprocessor == "image_processor":
																		lowercase_   : Optional[Any]   	=      AutoImageProcessor.from_pretrained(args.model				)
												elif args.preprocessor == "feature_extractor":
																		lowercase_   : Tuple   	=      AutoFeatureExtractor.from_pretrained(args.model				)
												elif args.preprocessor == "processor":
																		lowercase_   : Optional[int]   	=      AutoProcessor.from_pretrained(args.model				)
												else:
																		raise ValueError(f"Unknown preprocessor type '{args.preprocessor}'"				)

												# Ensure the requested opset is sufficient
												if args.opset is None:
																		lowercase_   : List[str]   	=      onnx_config.default_onnx_opset

												if args.opset < onnx_config.default_onnx_opset:
																		raise ValueError(
																		    f"Opset {args.opset} is not sufficient to export {model_kind}. "
																		    f"At least  {onnx_config.default_onnx_opset} is required."				)

												lowercase_	,   lowercase_   : str   	=      export(
												    a    ,      a    ,      a    ,      args.opset    ,      args.output    ,      )

												if args.atol is None:
																		lowercase_   : Dict   	=      onnx_config.atol_for_validation

												validate_model_outputs(a    ,      a    ,      a    ,      args.output    ,      a    ,      args.atol				)
												logger.info(f"All good, model saved at: {args.output.as_posix()}"				)
												warnings.warn(
												    'The export was done by transformers.onnx which is deprecated and will be removed in v5. We recommend'
												    ' using optimum.exporters.onnx in future. You can find more information here:'
												    ' https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/export_a_model.'    ,      a    ,      )






def 						_UpperCAmelCase     (	)      ->      List[Any]:





						"""simple docstring"""
						lowercase_   : Optional[int]   	=      ArgumentParser('Hugging Face Transformers ONNX exporter'				)
						parser.add_argument(
						    '-m'    ,      '--model'    ,      type=a    ,      required=a    ,      help='Model ID on huggingface.co or path on disk to load model from.'				)
						parser.add_argument(
						    '--feature'    ,      default='default'    ,      help='The type of features to export the model with.'    ,      )
						parser.add_argument('--opset'    ,      type=a    ,      default=a    ,      help='ONNX opset version to export the model with.'				)
						parser.add_argument(
						    '--atol'    ,      type=a    ,      default=a    ,      help='Absolute difference tolerance when validating the model.'				)
						parser.add_argument(
						    '--framework'    ,      type=a    ,      choices=['pt', 'tf']    ,      default=a    ,      help=(
						        'The framework to use for the ONNX export.'
						        ' If not provided, will attempt to use the local checkpoint\'s original framework'
						        ' or what is available in the environment.'
						    )    ,      )
						parser.add_argument('output'    ,      type=a    ,      help='Path indicating where to store generated ONNX model.'				)
						parser.add_argument('--cache_dir'    ,      type=a    ,      default=a    ,      help='Path indicating where to store cache.'				)
						parser.add_argument(
						    '--preprocessor'    ,      type=a    ,      choices=['auto', 'tokenizer', 'feature_extractor', 'image_processor', 'processor']    ,      default='auto'    ,      help='Which type of preprocessor to use. \'auto\' tries to automatically detect it.'    ,      )
						parser.add_argument(
						    '--export_with_transformers'    ,      action='store_true'    ,      help=(
						        'Whether to use transformers.onnx instead of optimum.exporters.onnx to perform the ONNX export. It can be '
						        'useful when exporting a model supported in transformers but not in optimum, otherwise it is not '
						        'recommended.'
						    )    ,      )

						lowercase_   : int   	=      parser.parse_args()
						if args.export_with_transformers or not is_optimum_available():
												export_with_transformers(a				)
						else:
												export_with_optimum(a				)


if __name__ == "__main__":
						A:   Union[str, Any]						=					logging.get_logger("transformers.onnx")  # pylint: disable=invalid-name
						logger.setLevel(logging.INFO)
						main()
