






import unittest

from transformers import AutoTokenizer, FalconConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers import (
							    FalconForCausalLM,
							    FalconForQuestionAnswering,
							    FalconForSequenceClassification,
							    FalconForTokenClassification,
							    FalconModel,
							)




class 		UpperCAmelCase_						:


						'''simple docstring'''




						def __init__(	self		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE=3		,				_SCREAMING_SNAKE_CASE=7		,				_SCREAMING_SNAKE_CASE=True		,				_SCREAMING_SNAKE_CASE=True		,				_SCREAMING_SNAKE_CASE=False		,				_SCREAMING_SNAKE_CASE=True		,				_SCREAMING_SNAKE_CASE=99		,				_SCREAMING_SNAKE_CASE=32		,				_SCREAMING_SNAKE_CASE=5		,				_SCREAMING_SNAKE_CASE=4		,				_SCREAMING_SNAKE_CASE=37		,				_SCREAMING_SNAKE_CASE="gelu"		,				_SCREAMING_SNAKE_CASE=0.1		,				_SCREAMING_SNAKE_CASE=0.1		,				_SCREAMING_SNAKE_CASE=512		,				_SCREAMING_SNAKE_CASE=16		,				_SCREAMING_SNAKE_CASE=2		,				_SCREAMING_SNAKE_CASE=0.02		,				_SCREAMING_SNAKE_CASE=3		,				_SCREAMING_SNAKE_CASE=4		,				_SCREAMING_SNAKE_CASE=None		,				) ->				Any:
								snake_case_				:							List[Any]						 =       parent
								snake_case_				:							Union[str, Any]						 =       batch_size
								snake_case_				:							int						 =       seq_length
								snake_case_				:							Optional[int]						 =       is_training
								snake_case_				:							Dict						 =       use_input_mask
								snake_case_				:							Tuple						 =       use_token_type_ids
								snake_case_				:							List[Any]						 =       use_labels
								snake_case_				:							Union[str, Any]						 =       vocab_size
								snake_case_				:							str						 =       hidden_size
								snake_case_				:							Optional[int]						 =       num_hidden_layers
								snake_case_				:							Any						 =       num_attention_heads
								snake_case_				:							Optional[int]						 =       intermediate_size
								snake_case_				:							int						 =       hidden_act
								snake_case_				:							List[Any]						 =       hidden_dropout_prob
								snake_case_				:							Union[str, Any]						 =       attention_probs_dropout_prob
								snake_case_				:							Tuple						 =       max_position_embeddings
								snake_case_				:							Any						 =       type_vocab_size
								snake_case_				:							Optional[int]						 =       type_sequence_label_size
								snake_case_				:							Optional[Any]						 =       initializer_range
								snake_case_				:							Dict						 =       num_labels
								snake_case_				:							int						 =       num_choices
								snake_case_				:							Tuple						 =       scope






						def       _lowerCAmelCase       (	self				) ->				Optional[int]:
								snake_case_				:							Any						 =       ids_tensor([self.batch_size, self.seq_length]		,				self.vocab_size				)

								snake_case_				:							int						 =       None
								if self.use_input_mask:
										snake_case_				:							Optional[Any]						 =       random_attention_mask([self.batch_size, self.seq_length]				)

								snake_case_				:							int						 =       None

								snake_case_				:							List[str]						 =       None
								snake_case_				:							Dict						 =       None
								snake_case_				:							str						 =       None
								if self.use_labels:
										snake_case_				:							Optional[Any]						 =       ids_tensor([self.batch_size]		,				self.type_sequence_label_size				)
										snake_case_				:							str						 =       ids_tensor([self.batch_size, self.seq_length]		,				self.num_labels				)
										snake_case_				:							Optional[int]						 =       ids_tensor([self.batch_size]		,				self.num_choices				)

								snake_case_				:							Optional[int]						 =       self.get_config()

								return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels






						def       _lowerCAmelCase       (	self				) ->				List[Any]:
								return FalconConfig(
								    vocab_size=self.vocab_size		,				hidden_size=self.hidden_size		,				num_hidden_layers=self.num_hidden_layers		,				num_attention_heads=self.num_attention_heads		,				intermediate_size=self.intermediate_size		,				hidden_act=self.hidden_act		,				hidden_dropout_prob=self.hidden_dropout_prob		,				attention_probs_dropout_prob=self.attention_probs_dropout_prob		,				max_position_embeddings=self.max_position_embeddings		,				type_vocab_size=self.type_vocab_size		,				is_decoder=_lowerCamelCase		,				initializer_range=self.initializer_range		,				pad_token_id=1		,				new_decoder_architecture=_lowerCamelCase		,				)






						def       _lowerCAmelCase       (	self		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE				) ->				Dict:
								snake_case_				:							List[str]						 =       FalconModel(config=_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							Any						 =       model(_lowerCamelCase		,				attention_mask=_lowerCamelCase				)
								snake_case_				:							Any						 =       model(_lowerCamelCase				)
								self.parent.assertEqual(result.last_hidden_state.shape		,				(self.batch_size, self.seq_length, self.hidden_size)				)






						def       _lowerCAmelCase       (	self		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				) ->				Tuple:
								snake_case_				:							str						 =       True
								snake_case_				:							Optional[int]						 =       FalconModel(_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							str						 =       model(
								    _lowerCamelCase		,				attention_mask=_lowerCamelCase		,				encoder_hidden_states=_lowerCamelCase		,				encoder_attention_mask=_lowerCamelCase		,				)
								snake_case_				:							Union[str, Any]						 =       model(
								    _lowerCamelCase		,				attention_mask=_lowerCamelCase		,				encoder_hidden_states=_lowerCamelCase		,				)
								snake_case_				:							Optional[Any]						 =       model(_lowerCamelCase		,				attention_mask=_lowerCamelCase				)
								self.parent.assertEqual(result.last_hidden_state.shape		,				(self.batch_size, self.seq_length, self.hidden_size)				)






						def       _lowerCAmelCase       (	self		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				) ->				Union[str, Any]:
								snake_case_				:							List[Any]						 =       FalconForCausalLM(config=_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							Any						 =       model(_lowerCamelCase		,				attention_mask=_lowerCamelCase		,				labels=_lowerCamelCase				)
								self.parent.assertEqual(result.logits.shape		,				(self.batch_size, self.seq_length, self.vocab_size)				)






						def       _lowerCAmelCase       (	self		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE		,				) ->				List[Any]:
								snake_case_				:							Any						 =       True
								snake_case_				:							Union[str, Any]						 =       True
								snake_case_				:							List[str]						 =       FalconForCausalLM(config=_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()

								# first forward pass
								snake_case_				:							List[str]						 =       model(
								    _lowerCamelCase		,				attention_mask=_lowerCamelCase		,				encoder_hidden_states=_lowerCamelCase		,				encoder_attention_mask=_lowerCamelCase		,				use_cache=_lowerCamelCase		,				)
								snake_case_				:							str						 =       outputs.past_key_values

								# create hypothetical multiple next token and extent to next_input_ids
								snake_case_				:							Dict						 =       ids_tensor((self.batch_size, 3)		,				config.vocab_size				)
								snake_case_				:							List[str]						 =       ids_tensor((self.batch_size, 3)		,				vocab_size=2				)

								# append to next input_ids and
								snake_case_				:							Dict						 =       torch.cat([input_ids, next_tokens]		,				dim=-1				)
								snake_case_				:							Union[str, Any]						 =       torch.cat([input_mask, next_mask]		,				dim=-1				)

								snake_case_				:							List[Any]						 =       model(
								    _lowerCamelCase		,				attention_mask=_lowerCamelCase		,				encoder_hidden_states=_lowerCamelCase		,				encoder_attention_mask=_lowerCamelCase		,				output_hidden_states=_lowerCamelCase		,				)["hidden_states"][0]
								snake_case_				:							List[str]						 =       model(
								    _lowerCamelCase		,				attention_mask=_lowerCamelCase		,				encoder_hidden_states=_lowerCamelCase		,				encoder_attention_mask=_lowerCamelCase		,				past_key_values=_lowerCamelCase		,				output_hidden_states=_lowerCamelCase		,				)["hidden_states"][0]

								# select random slice
								snake_case_				:							Any						 =       ids_tensor((1,)		,				output_from_past.shape[-1]				).item()
								snake_case_				:							List[str]						 =       output_from_no_past[:, -3:, random_slice_idx].detach()
								snake_case_				:							Any						 =       output_from_past[:, :, random_slice_idx].detach()

								self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]				)

								# test that outputs are equal for slice
								self.parent.assertTrue(torch.allclose(_lowerCamelCase		,				_lowerCamelCase		,				atol=1e-3				)				)






						def       _lowerCAmelCase       (	self				) ->				Dict:
								snake_case_				:							Union[str, Any]						 =       self.prepare_config_and_inputs()
								(
								    (
								    snake_case_	
								) ,       (
								    snake_case_	
								) ,       (
								    snake_case_	
								) ,       (
								    snake_case_	
								) ,       (
								    snake_case_	
								) ,       (
								    snake_case_	
								) ,       (
								    snake_case_	
								) ,       	
								)				:							List[Any]						 =       config_and_inputs
								snake_case_				:							Any						 =       {"input_ids": input_ids, "attention_mask": input_mask}
								return config, inputs_dict




@require_torch
class 		UpperCAmelCase_						(	__UpperCAmelCase					,  __UpperCAmelCase					,  __UpperCAmelCase					,  unittest.TestCase					):


						'''simple docstring'''




						A     :   Dict						=					(
						    (
						        FalconModel,
						        FalconForCausalLM,
						        FalconForSequenceClassification,
						        FalconForTokenClassification,
						        FalconForQuestionAnswering,
						    )
						    if is_torch_available()
						    else ()
						)
						A     :   Union[str, Any]						=					(FalconForCausalLM,) if is_torch_available() else ()
						A     :   str						=					(
						    {
						        "feature-extraction": FalconModel,
						        "text-classification": FalconForSequenceClassification,
						        "text-generation": FalconForCausalLM,
						        "question-answering": FalconForQuestionAnswering,
						        "token-classification": FalconForTokenClassification,
						        "zero-shot": FalconForSequenceClassification,
						    }
						    if is_torch_available()
						    else {}
						)
						A     :   List[str]						=					False
						A     :   List[Any]						=					False






						def       _lowerCAmelCase       (	self				) ->				int:
								snake_case_				:							Tuple						 =       FalconModelTester(self				)
								snake_case_				:							Optional[Any]						 =       ConfigTester(self		,				config_class=_lowerCamelCase		,				hidden_size=37				)






						def       _lowerCAmelCase       (	self				) ->				int:
								self.config_tester.run_common_tests()






						def       _lowerCAmelCase       (	self				) ->				Optional[int]:
								snake_case_				:							Optional[int]						 =       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*_lowerCamelCase				)






						def       _lowerCAmelCase       (	self				) ->				str:
								snake_case_ ,       *snake_case_				:							Tuple						 =       self.model_tester.prepare_config_and_inputs()
								for alibi in [True, False]:
										snake_case_				:							Optional[Any]						 =       alibi
										self.model_tester.create_and_check_model(_lowerCamelCase		,				*_lowerCamelCase				)






						def       _lowerCAmelCase       (	self				) ->				List[Any]:
								snake_case_ ,       snake_case_				:							str						 =       self.model_tester.prepare_config_and_inputs_for_common()
								snake_case_				:							List[Any]						 =       3
								snake_case_				:							Optional[int]						 =       input_dict["input_ids"]
								snake_case_				:							int						 =       input_ids.ne(1				).to(_lowerCamelCase				)
								snake_case_				:							Tuple						 =       ids_tensor([self.model_tester.batch_size]		,				self.model_tester.type_sequence_label_size				)
								snake_case_				:							Tuple						 =       FalconForSequenceClassification(_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							int						 =       model(_lowerCamelCase		,				attention_mask=_lowerCamelCase		,				labels=_lowerCamelCase				)
								self.assertEqual(result.logits.shape		,				(self.model_tester.batch_size, self.model_tester.num_labels)				)






						def       _lowerCAmelCase       (	self				) ->				int:
								snake_case_ ,       snake_case_				:							Any						 =       self.model_tester.prepare_config_and_inputs_for_common()
								snake_case_				:							Optional[int]						 =       3
								snake_case_				:							Optional[Any]						 =       "single_label_classification"
								snake_case_				:							List[Any]						 =       input_dict["input_ids"]
								snake_case_				:							Tuple						 =       input_ids.ne(1				).to(_lowerCamelCase				)
								snake_case_				:							Optional[Any]						 =       ids_tensor([self.model_tester.batch_size]		,				self.model_tester.type_sequence_label_size				)
								snake_case_				:							Any						 =       FalconForSequenceClassification(_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							Optional[int]						 =       model(_lowerCamelCase		,				attention_mask=_lowerCamelCase		,				labels=_lowerCamelCase				)
								self.assertEqual(result.logits.shape		,				(self.model_tester.batch_size, self.model_tester.num_labels)				)






						def       _lowerCAmelCase       (	self				) ->				Optional[Any]:
								snake_case_ ,       snake_case_				:							List[str]						 =       self.model_tester.prepare_config_and_inputs_for_common()
								snake_case_				:							Union[str, Any]						 =       input_dict["input_ids"]
								snake_case_				:							str						 =       FalconForCausalLM(_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							str						 =       model(_lowerCamelCase		,				use_cache=_lowerCamelCase				)
								snake_case_				:							int						 =       input_ids.shape[0]
								snake_case_				:							Optional[Any]						 =       model._convert_to_rw_cache(result.past_key_values				)
								snake_case_				:							List[str]						 =       model._convert_cache_to_standard_format(_lowerCamelCase		,				_lowerCamelCase				)
								for layer in range(len(_lowerCamelCase				)				):
										for tensor_idx in range(2				):
												self.assertTrue(rw_cache[layer][tensor_idx].ndim == 3				)
												self.assertTrue(result.past_key_values[layer][tensor_idx].ndim == 4				)
												self.assertTrue(
												    torch.all(result.past_key_values[layer][tensor_idx] == standard_cache[layer][tensor_idx]				)				)






						def       _lowerCAmelCase       (	self				) ->				Union[str, Any]:
								snake_case_ ,       snake_case_				:							Tuple						 =       self.model_tester.prepare_config_and_inputs_for_common()
								snake_case_				:							List[str]						 =       3
								snake_case_				:							List[Any]						 =       "multi_label_classification"
								snake_case_				:							List[str]						 =       input_dict["input_ids"]
								snake_case_				:							Any						 =       input_ids.ne(1				).to(_lowerCamelCase				)
								snake_case_				:							List[str]						 =       ids_tensor(
								    [self.model_tester.batch_size, config.num_labels]		,				self.model_tester.type_sequence_label_size				).to(torch.float				)
								snake_case_				:							Tuple						 =       FalconForSequenceClassification(_lowerCamelCase				)
								model.to(_lowerCamelCase				)
								model.eval()
								snake_case_				:							List[Any]						 =       model(_lowerCamelCase		,				attention_mask=_lowerCamelCase		,				labels=_lowerCamelCase				)
								self.assertEqual(result.logits.shape		,				(self.model_tester.batch_size, self.model_tester.num_labels)				)






						def       _lowerCAmelCase       (	self				) ->				List[Any]:
								# Falcon can have different numbers of KV-heads than the number of query heads, so we need
								# to override this test to use the right head counts.
								for model_class in self.all_generative_model_classes:
										snake_case_ ,       snake_case_				:							Dict						 =       self.model_tester.prepare_config_and_inputs_for_common()

										# If it doesn't support cache, pass the test
										if not hasattr(_lowerCamelCase		,				"use_cache"				):
												return

										snake_case_				:							int						 =       model_class(_lowerCamelCase				).to(_lowerCamelCase				)
										if "use_cache" not in inputs:
												snake_case_				:							Tuple						 =       True
										snake_case_				:							Dict						 =       model(**_lowerCamelCase				)

										# If "past_key_values" is not returned, pass the test (e.g. RWKV uses a different cache name and format)
										if "past_key_values" not in outputs:
												return

										snake_case_				:							List[str]						 =       (
										    getattr(_lowerCamelCase		,				"decoder_layers"		,				_lowerCamelCase				)
										    or getattr(_lowerCamelCase		,				"num_decoder_layers"		,				_lowerCamelCase				)
										    or config.num_hidden_layers
										)
										snake_case_				:							Any						 =       getattr(_lowerCamelCase		,				"num_kv_heads"		,				config.num_attention_heads				)
										snake_case_				:							str						 =       getattr(_lowerCamelCase		,				"d_model"		,				config.hidden_size				)
										snake_case_				:							Dict						 =       embed_dim // num_attention_heads

										snake_case_				:							int						 =       outputs["past_key_values"]
										self.assertEqual(len(_lowerCamelCase				)		,				_lowerCamelCase				)

										snake_case_ ,       snake_case_				:							int						 =       inputs["input_ids"].shape
										for i in range(_lowerCamelCase				):
												if config.new_decoder_architecture:
														snake_case_				:							Tuple						 =       config.num_attention_heads
												elif config.multi_query:
														snake_case_				:							Optional[int]						 =       1
												self.assertEqual(len(past_kv[0]				)		,				2				)  # K V for the decoder = 2
												self.assertEqual(
												    past_kv[i][0].shape		,				(batch_size, num_attention_heads, seq_length, per_head_embed_dim)				)
												self.assertEqual(
												    past_kv[i][1].shape		,				(batch_size, num_attention_heads, seq_length, per_head_embed_dim)				)




@require_torch
class 		UpperCAmelCase_						(	unittest.TestCase					):


						'''simple docstring'''




						@slow
						def       _lowerCAmelCase       (	self				) ->				str:
								snake_case_				:							int						 =       AutoTokenizer.from_pretrained("Rocketknight1/falcon-rw-1b"				)
								snake_case_				:							Optional[int]						 =       FalconForCausalLM.from_pretrained("Rocketknight1/falcon-rw-1b"				)
								model.eval()
								model.to(_lowerCamelCase				)
								snake_case_				:							Dict						 =       tokenizer("My favorite food is"		,				return_tensors="pt"				).to(_lowerCamelCase				)

								snake_case_				:							List[str]						 =       (
								    "My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday."
								)

								snake_case_				:							Union[str, Any]						 =       model.generate(**_lowerCamelCase		,				do_sample=_lowerCamelCase		,				max_new_tokens=19				)
								snake_case_				:							List[Any]						 =       tokenizer.batch_decode(_lowerCamelCase				)[0]

								self.assertEqual(_lowerCamelCase		,				_lowerCamelCase				)






						@slow
						def       _lowerCAmelCase       (	self				) ->				Tuple:
								# The big models are way too big for the CI, so we use tiny random models that resemble their
								# architectures but with much smaller and fewer layers
								for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
										snake_case_				:							Dict						 =       AutoTokenizer.from_pretrained(_lowerCamelCase				)
										snake_case_				:							int						 =       FalconForCausalLM.from_pretrained(_lowerCamelCase				)
										model.eval()
										model.to(_lowerCamelCase				)
										snake_case_				:							Any						 =       tokenizer("My favorite food is"		,				return_tensors="pt"				).to(_lowerCamelCase				)

										# We just test that these run without errors - the models are randomly initialized
										# and so the actual text outputs will be garbage
										model.generate(**_lowerCamelCase		,				do_sample=_lowerCamelCase		,				max_new_tokens=4				)
										model.generate(**_lowerCamelCase		,				do_sample=_lowerCamelCase		,				max_new_tokens=4				)
										model.generate(**_lowerCamelCase		,				num_beams=2		,				max_new_tokens=4				)






						@slow
						def       _lowerCAmelCase       (	self				) ->				Tuple:
								# The big models are way too big for the CI, so we use tiny random models that resemble their
								# architectures but with much smaller and fewer layers
								with torch.no_grad():
										for repo in [
										    "Rocketknight1/falcon-rw-1b",
										    "Rocketknight1/tiny-random-falcon-7b",
										    "Rocketknight1/tiny-random-falcon-40b",
										]:
												snake_case_				:							List[str]						 =       AutoTokenizer.from_pretrained(_lowerCamelCase				)
												snake_case_				:							str						 =       FalconForCausalLM.from_pretrained(_lowerCamelCase				)
												model.eval()
												model.to(device=_lowerCamelCase				)
												snake_case_				:							List[Any]						 =       tokenizer("My favorite food is"		,				return_tensors="pt"				).to(_lowerCamelCase				)

												# Test results are the same with and without cache
												snake_case_				:							List[str]						 =       model.generate(**_lowerCamelCase		,				do_sample=_lowerCamelCase		,				max_new_tokens=20		,				use_cache=_lowerCamelCase				)
												snake_case_				:							Optional[int]						 =       model.generate(**_lowerCamelCase		,				do_sample=_lowerCamelCase		,				max_new_tokens=20		,				use_cache=_lowerCamelCase				)
												self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0				)








from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowercase  :							Union[str, Any]			  =    {'''configuration_xglm''': ['''XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XGLMConfig''']}

try:
							if not is_sentencepiece_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							Optional[int]			  =    ['''XGLMTokenizer''']

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							Tuple			  =    ['''XGLMTokenizerFast''']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							str			  =    [
							    '''XGLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''XGLMForCausalLM''',
							    '''XGLMModel''',
							    '''XGLMPreTrainedModel''',
							]


try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							str			  =    [
							    '''FlaxXGLMForCausalLM''',
							    '''FlaxXGLMModel''',
							    '''FlaxXGLMPreTrainedModel''',
							]


try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							Tuple			  =    [
							    '''TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''TFXGLMForCausalLM''',
							    '''TFXGLMModel''',
							    '''TFXGLMPreTrainedModel''',
							]


if TYPE_CHECKING:
							from .configuration_xglm import XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XGLMConfig

							try:
														if not is_sentencepiece_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_xglm import XGLMTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_xglm_fast import XGLMTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_xglm import XGLM_PRETRAINED_MODEL_ARCHIVE_LIST, XGLMForCausalLM, XGLMModel, XGLMPreTrainedModel

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_flax_xglm import FlaxXGLMForCausalLM, FlaxXGLMModel, FlaxXGLMPreTrainedModel

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_xglm import (
														    TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST,
														    TFXGLMForCausalLM,
														    TFXGLMModel,
														    TFXGLMPreTrainedModel,
														)


else:
							import sys

							lowercase  :							Dict			  =    _LazyModule(__name__, globals()['''__file__'''], _import_structure)
