
"""simple docstring"""



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 							_SCREAMING_SNAKE_CASE	:






				'''simple docstring'''



				def __init__(       self						:      str					,  UpperCAmelCase_						:      Optional[Any]					,  UpperCAmelCase_						:      List[str]=3					,  UpperCAmelCase_						:      Any=7					,  UpperCAmelCase_						:      Optional[Any]=True					,  UpperCAmelCase_						:      int=True					,  UpperCAmelCase_						:      List[str]=False					,  UpperCAmelCase_						:      Optional[int]=True					,  UpperCAmelCase_						:      int=99					,  UpperCAmelCase_						:      Optional[int]=32					,  UpperCAmelCase_						:      List[str]=5					,  UpperCAmelCase_						:      Any=4					,  UpperCAmelCase_						:      str=37					,  UpperCAmelCase_						:      int="gelu"					,  UpperCAmelCase_						:      Any=0.1					,  UpperCAmelCase_						:      Tuple=0.1					,  UpperCAmelCase_						:      Any=512					,  UpperCAmelCase_						:      Dict=16					,  UpperCAmelCase_						:      int=2					,  UpperCAmelCase_						:      int=0.02					,  UpperCAmelCase_						:      List[str]=3					,  UpperCAmelCase_						:      Any=4					,  UpperCAmelCase_						:      Optional[Any]=None					,  )		->	str:







											"""simple docstring"""




											_lowerCAmelCase							=      parent
											_lowerCAmelCase							=      batch_size
											_lowerCAmelCase							=      seq_length
											_lowerCAmelCase							=      is_training
											_lowerCAmelCase							=      use_input_mask
											_lowerCAmelCase							=      use_token_type_ids
											_lowerCAmelCase							=      use_labels
											_lowerCAmelCase							=      vocab_size
											_lowerCAmelCase							=      hidden_size
											_lowerCAmelCase							=      num_hidden_layers
											_lowerCAmelCase							=      num_attention_heads
											_lowerCAmelCase							=      intermediate_size
											_lowerCAmelCase							=      hidden_act
											_lowerCAmelCase							=      hidden_dropout_prob
											_lowerCAmelCase							=      attention_probs_dropout_prob
											_lowerCAmelCase							=      max_position_embeddings
											_lowerCAmelCase							=      type_vocab_size
											_lowerCAmelCase							=      type_sequence_label_size
											_lowerCAmelCase							=      initializer_range
											_lowerCAmelCase							=      num_labels
											_lowerCAmelCase							=      num_choices
											_lowerCAmelCase							=      scope


				def 					__lowerCamelCase						(       self						:      int	)		->	Optional[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      ids_tensor([self.batch_size, self.seq_length]					,  self.vocab_size	)

											_lowerCAmelCase							=      None
											if self.use_input_mask:
																		_lowerCAmelCase							=      random_attention_mask([self.batch_size, self.seq_length]	)

											_lowerCAmelCase							=      None

											_lowerCAmelCase							=      None
											_lowerCAmelCase							=      None
											_lowerCAmelCase							=      None
											if self.use_labels:
																		_lowerCAmelCase							=      ids_tensor([self.batch_size]					,  self.type_sequence_label_size	)
																		_lowerCAmelCase							=      ids_tensor([self.batch_size, self.seq_length]					,  self.num_labels	)
																		_lowerCAmelCase							=      ids_tensor([self.batch_size]					,  self.num_choices	)

											_lowerCAmelCase							=      self.get_config()

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


				def 					__lowerCamelCase						(       self						:      Tuple	)		->	Dict:







											"""simple docstring"""




											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=UpperCAmelCase_					,  initializer_range=self.initializer_range					,  pad_token_id=1					,  new_decoder_architecture=UpperCAmelCase_					,  )


				def 					__lowerCamelCase						(       self						:      List[str]					,  UpperCAmelCase_						:      List[str]					,  UpperCAmelCase_						:      int					,  UpperCAmelCase_						:      List[str]					,  UpperCAmelCase_						:      List[Any]					,  UpperCAmelCase_						:      int					,  UpperCAmelCase_						:      int					,  UpperCAmelCase_						:      List[Any]	)		->	Tuple:







											"""simple docstring"""




											_lowerCAmelCase							=      FalconModel(config=UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  attention_mask=UpperCAmelCase_	)
											_lowerCAmelCase							=      model(UpperCAmelCase_	)
											self.parent.assertEqual(result.last_hidden_state.shape					,  (self.batch_size, self.seq_length, self.hidden_size)	)


				def 					__lowerCamelCase						(       self						:      Dict					,  UpperCAmelCase_						:      Any					,  UpperCAmelCase_						:      Optional[Any]					,  UpperCAmelCase_						:      Union[str, Any]					,  UpperCAmelCase_						:      Any					,  UpperCAmelCase_						:      Optional[int]					,  UpperCAmelCase_						:      Any					,  UpperCAmelCase_						:      List[str]					,  UpperCAmelCase_						:      Optional[int]					,  UpperCAmelCase_						:      Optional[int]					,  )		->	int:







											"""simple docstring"""




											_lowerCAmelCase							=      True
											_lowerCAmelCase							=      FalconModel(UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(
											    UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  encoder_hidden_states=UpperCAmelCase_					,  encoder_attention_mask=UpperCAmelCase_					,  )
											_lowerCAmelCase							=      model(
											    UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  encoder_hidden_states=UpperCAmelCase_					,  )
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  attention_mask=UpperCAmelCase_	)
											self.parent.assertEqual(result.last_hidden_state.shape					,  (self.batch_size, self.seq_length, self.hidden_size)	)


				def 					__lowerCamelCase						(       self						:      Optional[int]					,  UpperCAmelCase_						:      int					,  UpperCAmelCase_						:      Optional[int]					,  UpperCAmelCase_						:      Union[str, Any]					,  UpperCAmelCase_						:      Optional[int]					,  UpperCAmelCase_						:      List[Any]					,  UpperCAmelCase_						:      int					,  UpperCAmelCase_						:      List[Any]					,  UpperCAmelCase_						:      Dict					,  UpperCAmelCase_						:      int					,  )		->	Tuple:







											"""simple docstring"""




											_lowerCAmelCase							=      FalconForCausalLM(config=UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  labels=UpperCAmelCase_	)
											self.parent.assertEqual(result.logits.shape					,  (self.batch_size, self.seq_length, self.vocab_size)	)


				def 					__lowerCamelCase						(       self						:      List[Any]					,  UpperCAmelCase_						:      Optional[int]					,  UpperCAmelCase_						:      List[Any]					,  UpperCAmelCase_						:      str					,  UpperCAmelCase_						:      List[Any]					,  UpperCAmelCase_						:      Optional[int]					,  UpperCAmelCase_						:      Union[str, Any]					,  UpperCAmelCase_						:      Tuple					,  UpperCAmelCase_						:      List[Any]					,  UpperCAmelCase_						:      Optional[Any]					,  )		->	List[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      True
											_lowerCAmelCase							=      True
											_lowerCAmelCase							=      FalconForCausalLM(config=UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()

											# first forward pass
											_lowerCAmelCase							=      model(
											    UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  encoder_hidden_states=UpperCAmelCase_					,  encoder_attention_mask=UpperCAmelCase_					,  use_cache=UpperCAmelCase_					,  )
											_lowerCAmelCase							=      outputs.past_key_values

											# create hypothetical multiple next token and extent to next_input_ids
											_lowerCAmelCase							=      ids_tensor((self.batch_size, 3)					,  config.vocab_size	)
											_lowerCAmelCase							=      ids_tensor((self.batch_size, 3)					,  vocab_size=2	)

											# append to next input_ids and
											_lowerCAmelCase							=      torch.cat([input_ids, next_tokens]					,  dim=-1	)
											_lowerCAmelCase							=      torch.cat([input_mask, next_mask]					,  dim=-1	)

											_lowerCAmelCase							=      model(
											    UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  encoder_hidden_states=UpperCAmelCase_					,  encoder_attention_mask=UpperCAmelCase_					,  output_hidden_states=UpperCAmelCase_					,  )['hidden_states'][0]
											_lowerCAmelCase							=      model(
											    UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  encoder_hidden_states=UpperCAmelCase_					,  encoder_attention_mask=UpperCAmelCase_					,  past_key_values=UpperCAmelCase_					,  output_hidden_states=UpperCAmelCase_					,  )['hidden_states'][0]

											# select random slice
											_lowerCAmelCase							=      ids_tensor((1,)					,  output_from_past.shape[-1]	).item()
											_lowerCAmelCase							=      output_from_no_past[:, -3:, random_slice_idx].detach()
											_lowerCAmelCase							=      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(UpperCAmelCase_					,  UpperCAmelCase_					,  atol=1E-3	)	)







				def 					__lowerCamelCase						(       self						:      List[Any]	)		->	Union[str, Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      self.prepare_config_and_inputs()
											(
											    _lowerCAmelCase							
											)							=      config_and_inputs
											_lowerCAmelCase							=      {'input_ids': input_ids, 'attention_mask': input_mask}
											return config, inputs_dict






@require_torch
class 							_SCREAMING_SNAKE_CASE	(	_a   ,					_a   ,					_a   ,					unittest.TestCase				):






				'''simple docstring'''



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


				def 					__lowerCamelCase						(       self						:      Optional[Any]	)		->	Dict:







											"""simple docstring"""




											_lowerCAmelCase							=      FalconModelTester(self	)
											_lowerCAmelCase							=      ConfigTester(self					,  config_class=UpperCAmelCase_					,  hidden_size=37	)


				def 					__lowerCamelCase						(       self						:      Optional[Any]	)		->	str:







											"""simple docstring"""




											self.config_tester.run_common_tests()


				def 					__lowerCamelCase						(       self						:      Union[str, Any]	)		->	List[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*UpperCAmelCase_	)


				def 					__lowerCamelCase						(       self						:      Any	)		->	Optional[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs()
											for alibi in [True, False]:
																		_lowerCAmelCase							=      alibi
																		self.model_tester.create_and_check_model(UpperCAmelCase_					,  *UpperCAmelCase_	)


				def 					__lowerCamelCase						(       self						:      Optional[int]	)		->	Optional[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs_for_common()
											_lowerCAmelCase							=      3
											_lowerCAmelCase							=      input_dict['input_ids']
											_lowerCAmelCase							=      input_ids.ne(1	).to(UpperCAmelCase_	)
											_lowerCAmelCase							=      ids_tensor([self.model_tester.batch_size]					,  self.model_tester.type_sequence_label_size	)
											_lowerCAmelCase							=      FalconForSequenceClassification(UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  labels=UpperCAmelCase_	)
											self.assertEqual(result.logits.shape					,  (self.model_tester.batch_size, self.model_tester.num_labels)	)


				def 					__lowerCamelCase						(       self						:      int	)		->	List[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs_for_common()
											_lowerCAmelCase							=      3
											_lowerCAmelCase							=      'single_label_classification'
											_lowerCAmelCase							=      input_dict['input_ids']
											_lowerCAmelCase							=      input_ids.ne(1	).to(UpperCAmelCase_	)
											_lowerCAmelCase							=      ids_tensor([self.model_tester.batch_size]					,  self.model_tester.type_sequence_label_size	)
											_lowerCAmelCase							=      FalconForSequenceClassification(UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  labels=UpperCAmelCase_	)
											self.assertEqual(result.logits.shape					,  (self.model_tester.batch_size, self.model_tester.num_labels)	)


				def 					__lowerCamelCase						(       self						:      int	)		->	Dict:







											"""simple docstring"""




											_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs_for_common()
											_lowerCAmelCase							=      input_dict['input_ids']
											_lowerCAmelCase							=      FalconForCausalLM(UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  use_cache=UpperCAmelCase_	)
											_lowerCAmelCase							=      input_ids.shape[0]
											_lowerCAmelCase							=      model._convert_to_rw_cache(result.past_key_values	)
											_lowerCAmelCase							=      model._convert_cache_to_standard_format(UpperCAmelCase_					,  UpperCAmelCase_	)
											for layer in range(len(UpperCAmelCase_	)	):
																		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						:      Optional[Any]	)		->	Optional[Any]:







											"""simple docstring"""




											_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs_for_common()
											_lowerCAmelCase							=      3
											_lowerCAmelCase							=      'multi_label_classification'
											_lowerCAmelCase							=      input_dict['input_ids']
											_lowerCAmelCase							=      input_ids.ne(1	).to(UpperCAmelCase_	)
											_lowerCAmelCase							=      ids_tensor(
											    [self.model_tester.batch_size, config.num_labels]					,  self.model_tester.type_sequence_label_size	).to(torch.float	)
											_lowerCAmelCase							=      FalconForSequenceClassification(UpperCAmelCase_	)
											model.to(UpperCAmelCase_	)
											model.eval()
											_lowerCAmelCase							=      model(UpperCAmelCase_					,  attention_mask=UpperCAmelCase_					,  labels=UpperCAmelCase_	)
											self.assertEqual(result.logits.shape					,  (self.model_tester.batch_size, self.model_tester.num_labels)	)







				def 					__lowerCamelCase						(       self						:      Optional[Any]	)		->	Optional[int]:







											"""simple docstring"""




											for model_class in self.all_generative_model_classes:
																		_lowerCAmelCase							=      self.model_tester.prepare_config_and_inputs_for_common()

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

																		_lowerCAmelCase							=      model_class(UpperCAmelCase_	).to(UpperCAmelCase_	)
																		if "use_cache" not in inputs:
																									_lowerCAmelCase							=      True
																		_lowerCAmelCase							=      model(**UpperCAmelCase_	)

																		# 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

																		_lowerCAmelCase							=      (
																		    getattr(UpperCAmelCase_					,  'decoder_layers'					,  UpperCAmelCase_	)
																		    or getattr(UpperCAmelCase_					,  'num_decoder_layers'					,  UpperCAmelCase_	)
																		    or config.num_hidden_layers
																		)
																		_lowerCAmelCase							=      getattr(UpperCAmelCase_					,  'num_kv_heads'					,  config.num_attention_heads	)
																		_lowerCAmelCase							=      getattr(UpperCAmelCase_					,  'd_model'					,  config.hidden_size	)
																		_lowerCAmelCase							=      embed_dim // num_attention_heads

																		_lowerCAmelCase							=      outputs['past_key_values']
																		self.assertEqual(len(UpperCAmelCase_	)					,  UpperCAmelCase_	)

																		_lowerCAmelCase							=      inputs['input_ids'].shape
																		for i in range(UpperCAmelCase_	):
																									if config.new_decoder_architecture:
																																_lowerCAmelCase							=      config.num_attention_heads
																									elif config.multi_query:
																																_lowerCAmelCase							=      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 							_SCREAMING_SNAKE_CASE	(	unittest.TestCase				):






				'''simple docstring'''



				@slow
				def 					__lowerCamelCase						(       self						:      Tuple	)		->	int:







											"""simple docstring"""




											_lowerCAmelCase							=      AutoTokenizer.from_pretrained('Rocketknight1/falcon-rw-1b'	)
											_lowerCAmelCase							=      FalconForCausalLM.from_pretrained('Rocketknight1/falcon-rw-1b'	)
											model.eval()
											model.to(UpperCAmelCase_	)
											_lowerCAmelCase							=      tokenizer('My favorite food is'					,  return_tensors='pt'	).to(UpperCAmelCase_	)

											_lowerCAmelCase							=      (
											    'My favorite food is pizza. I love it so much that I have a pizza party every year for my birthday.'
											)

											_lowerCAmelCase							=      model.generate(**UpperCAmelCase_					,  do_sample=UpperCAmelCase_					,  max_new_tokens=19	)
											_lowerCAmelCase							=      tokenizer.batch_decode(UpperCAmelCase_	)[0]

											self.assertEqual(UpperCAmelCase_					,  UpperCAmelCase_	)


				@slow
				def 					__lowerCamelCase						(       self						:      Optional[int]	)		->	Optional[Any]:







											"""simple docstring"""




											for repo in ["Rocketknight1/tiny-random-falcon-7b", "Rocketknight1/tiny-random-falcon-40b"]:
																		_lowerCAmelCase							=      AutoTokenizer.from_pretrained(UpperCAmelCase_	)
																		_lowerCAmelCase							=      FalconForCausalLM.from_pretrained(UpperCAmelCase_	)
																		model.eval()
																		model.to(UpperCAmelCase_	)
																		_lowerCAmelCase							=      tokenizer('My favorite food is'					,  return_tensors='pt'	).to(UpperCAmelCase_	)

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







				@slow
				def 					__lowerCamelCase						(       self						:      Dict	)		->	Union[str, Any]:







											"""simple docstring"""




											with torch.no_grad():
																		for repo in [
																		    "Rocketknight1/falcon-rw-1b",
																		    "Rocketknight1/tiny-random-falcon-7b",
																		    "Rocketknight1/tiny-random-falcon-40b",
																		]:
																									_lowerCAmelCase							=      AutoTokenizer.from_pretrained(UpperCAmelCase_	)
																									_lowerCAmelCase							=      FalconForCausalLM.from_pretrained(UpperCAmelCase_	)
																									model.eval()
																									model.to(device=UpperCAmelCase_	)
																									_lowerCAmelCase							=      tokenizer('My favorite food is'					,  return_tensors='pt'	).to(UpperCAmelCase_	)

																									# Test results are the same with and without cache
																									_lowerCAmelCase							=      model.generate(**UpperCAmelCase_					,  do_sample=UpperCAmelCase_					,  max_new_tokens=20					,  use_cache=UpperCAmelCase_	)
																									_lowerCAmelCase							=      model.generate(**UpperCAmelCase_					,  do_sample=UpperCAmelCase_					,  max_new_tokens=20					,  use_cache=UpperCAmelCase_	)
																									self.assertTrue((outputs_cache - outputs_no_cache).sum().item() == 0	)










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


SCREAMING_SNAKE_CASE			: List[Any]				   =					{
    "configuration_poolformer": [
        "POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "PoolFormerConfig",
        "PoolFormerOnnxConfig",
    ]
}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE			: List[str]				   =					["PoolFormerFeatureExtractor"]
 SCREAMING_SNAKE_CASE			: List[Any]				   =					["PoolFormerImageProcessor"]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE			: List[Any]				   =					[
     "POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
     "PoolFormerForImageClassification",
     "PoolFormerModel",
     "PoolFormerPreTrainedModel",
 ]


if TYPE_CHECKING:
 from .configuration_poolformer import (
     POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
     PoolFormerConfig,
     PoolFormerOnnxConfig,
 )

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_poolformer import PoolFormerFeatureExtractor
  from .image_processing_poolformer import PoolFormerImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_poolformer import (
      POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
      PoolFormerForImageClassification,
      PoolFormerModel,
      PoolFormerPreTrainedModel,
  )


else:
 import sys

 SCREAMING_SNAKE_CASE			: str				   =					_LazyModule(__name__, globals()["__file__"], _import_structure)


