


'''simple docstring'''
import math
import unittest

from transformers import BioGptConfig, 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 (
      BioGptForCausalLM,
      BioGptForSequenceClassification,
      BioGptForTokenClassification,
      BioGptModel,
      BioGptTokenizer,
  )
  from transformers.models.biogpt.modeling_biogpt import BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST




class 			lowerCamelCase_   :






      def __init__(					self				:    int						,						_A				:    str						,						_A				:    Optional[Any]=13						,						_A				:    Tuple=7						,						_A				:    Dict=True						,						_A				:    Any=True						,						_A				:    str=False						,						_A				:    str=True						,						_A				:    List[str]=99						,						_A				:    Tuple=32						,						_A				:    str=5						,						_A				:    List[Any]=4						,						_A				:    str=37						,						_A				:    Tuple="gelu"						,						_A				:    List[str]=0.1						,						_A				:    Any=0.1						,						_A				:    str=512						,						_A				:    List[str]=16						,						_A				:    Union[str, Any]=2						,						_A				:    Any=0.0_2						,						_A				:    Any=3						,						_A				:    Dict=4						,						_A				:    Optional[Any]=None						,						):


          '''simple docstring'''


          UpperCAmelCase__			:		Tuple													=				parent
          UpperCAmelCase__			:		Optional[int]													=				batch_size
          UpperCAmelCase__			:		Dict													=				seq_length
          UpperCAmelCase__			:		Dict													=				is_training
          UpperCAmelCase__			:		Union[str, Any]													=				use_input_mask
          UpperCAmelCase__			:		Dict													=				use_token_type_ids
          UpperCAmelCase__			:		Any													=				use_labels
          UpperCAmelCase__			:		Optional[Any]													=				vocab_size
          UpperCAmelCase__			:		Any													=				hidden_size
          UpperCAmelCase__			:		Union[str, Any]													=				num_hidden_layers
          UpperCAmelCase__			:		Union[str, Any]													=				num_attention_heads
          UpperCAmelCase__			:		List[str]													=				intermediate_size
          UpperCAmelCase__			:		Union[str, Any]													=				hidden_act
          UpperCAmelCase__			:		Dict													=				hidden_dropout_prob
          UpperCAmelCase__			:		Dict													=				attention_probs_dropout_prob
          UpperCAmelCase__			:		Optional[int]													=				max_position_embeddings
          UpperCAmelCase__			:		Optional[int]													=				type_vocab_size
          UpperCAmelCase__			:		str													=				type_sequence_label_size
          UpperCAmelCase__			:		Union[str, Any]													=				initializer_range
          UpperCAmelCase__			:		List[Any]													=				num_labels
          UpperCAmelCase__			:		List[str]													=				num_choices
          UpperCAmelCase__			:		int													=				scope






      def lowercase_							(					self				:    List[str] ):


          '''simple docstring'''


          UpperCAmelCase__			:		Any													=				ids_tensor([self.batch_size, self.seq_length]						,						self.vocab_size )

          UpperCAmelCase__			:		Optional[int]													=				None
          if self.use_input_mask:
              UpperCAmelCase__			:		List[str]													=				random_attention_mask([self.batch_size, self.seq_length] )

          UpperCAmelCase__			:		List[Any]													=				None
          if self.use_token_type_ids:
              UpperCAmelCase__			:		Tuple													=				ids_tensor([self.batch_size, self.seq_length]						,						self.type_vocab_size )

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

          UpperCAmelCase__			:		List[str]													=				self.get_config()

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






      def lowercase_							(					self				:    str ):


          '''simple docstring'''


          return BioGptConfig(
              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=_A						,						initializer_range=self.initializer_range						,						)






      def lowercase_							(					self				:    Tuple						,						_A				:    Union[str, Any]						,						_A				:    int						,						_A				:    Optional[Any]						,						_A				:    List[Any]						,						_A				:    Any						,						_A				:    Optional[int]						,						_A				:    str ):


          '''simple docstring'''


          UpperCAmelCase__			:		List[str]													=				BioGptModel(config=_A )
          model.to(_A )
          model.eval()
          UpperCAmelCase__			:		Tuple													=				model(_A						,						attention_mask=_A )
          UpperCAmelCase__			:		str													=				model(_A )
          self.parent.assertEqual(result.last_hidden_state.shape						,						(self.batch_size, self.seq_length, self.hidden_size) )






      def lowercase_							(					self				:    List[Any]						,						_A				:    Dict						,						_A				:    Optional[Any]						,						_A				:    Dict						,						_A				:    int						,						_A				:    Optional[Any]						,						_A				:    List[Any]						,						_A				:    int						,						_A				:    List[str]						,						_A				:    str						,						):


          '''simple docstring'''


          UpperCAmelCase__			:		List[str]													=				BioGptForCausalLM(config=_A )
          model.to(_A )
          model.eval()
          UpperCAmelCase__			:		str													=				model(_A						,						attention_mask=_A						,						token_type_ids=_A						,						labels=_A )
          self.parent.assertEqual(result.logits.shape						,						(self.batch_size, self.seq_length, self.vocab_size) )






      def lowercase_							(					self				:    Tuple						,						_A				:    Any						,						_A				:    List[Any]						,						_A				:    Dict						,						_A				:    Optional[Any]						,						_A				:    Optional[Any]						,						*_A				:    Dict ):


          '''simple docstring'''


          UpperCAmelCase__			:		Any													=				BioGptModel(config=_A )
          model.to(_A )
          model.eval()

          # create attention mask
          UpperCAmelCase__			:		List[str]													=				torch.ones(input_ids.shape						,						dtype=torch.long						,						device=_A )
          UpperCAmelCase__			:		str													=				self.seq_length // 2
          UpperCAmelCase__			:		Union[str, Any]													=				0

          # first forward pass
          UpperCAmelCase__						,						UpperCAmelCase__			:		List[str]													=				model(_A						,						attention_mask=_A ).to_tuple()

          # create hypothetical next token and extent to next_input_ids
          UpperCAmelCase__			:		Optional[int]													=				ids_tensor((self.batch_size, 1)						,						config.vocab_size )

          # change a random masked slice from input_ids
          UpperCAmelCase__			:		List[Any]													=				ids_tensor((1,)						,						_A ).item() + 1
          UpperCAmelCase__			:		str													=				ids_tensor((self.batch_size, 1)						,						config.vocab_size ).squeeze(-1 )
          UpperCAmelCase__			:		str													=				random_other_next_tokens

          # append to next input_ids and attn_mask
          UpperCAmelCase__			:		str													=				torch.cat([input_ids, next_tokens]						,						dim=-1 )
          UpperCAmelCase__			:		int													=				torch.cat(
              [attn_mask, torch.ones((attn_mask.shape[0], 1)						,						dtype=torch.long						,						device=_A )]						,						dim=1						,						)

          # get two different outputs
          UpperCAmelCase__			:		Any													=				model(_A						,						attention_mask=_A )['''last_hidden_state''']
          UpperCAmelCase__			:		Optional[int]													=				model(_A						,						past_key_values=_A						,						attention_mask=_A )['''last_hidden_state''']

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

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






      def lowercase_							(					self				:    Tuple						,						_A				:    Any						,						_A				:    List[Any]						,						_A				:    List[Any]						,						_A				:    Any						,						_A				:    str						,						*_A				:    str ):


          '''simple docstring'''


          UpperCAmelCase__			:		Union[str, Any]													=				BioGptModel(config=_A ).to(_A ).eval()

          UpperCAmelCase__			:		str													=				torch.ones(input_ids.shape						,						dtype=torch.long						,						device=_A )

          # first forward pass
          UpperCAmelCase__			:		List[str]													=				model(_A						,						attention_mask=_A						,						use_cache=_A )

          UpperCAmelCase__						,						UpperCAmelCase__			:		Optional[int]													=				outputs.to_tuple()

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

          # append to next input_ids and
          UpperCAmelCase__			:		int													=				torch.cat([input_ids, next_tokens]						,						dim=-1 )
          UpperCAmelCase__			:		List[str]													=				torch.cat([attention_mask, next_attn_mask]						,						dim=-1 )

          UpperCAmelCase__			:		Dict													=				model(_A						,						attention_mask=_A )['''last_hidden_state''']
          UpperCAmelCase__			:		Dict													=				model(_A						,						attention_mask=_A						,						past_key_values=_A )[
              '''last_hidden_state'''
          ]

          # select random slice
          UpperCAmelCase__			:		Union[str, Any]													=				ids_tensor((1,)						,						output_from_past.shape[-1] ).item()
          UpperCAmelCase__			:		List[str]													=				output_from_no_past[:, -3:, random_slice_idx].detach()
          UpperCAmelCase__			:		List[str]													=				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(_A						,						_A						,						atol=1e-3 ) )






      def lowercase_							(					self				:    Any						,						_A				:    List[Any]						,						_A				:    Optional[Any]						,						_A				:    str						,						_A				:    Union[str, Any]						,						_A				:    Optional[int]						,						*_A				:    List[Any]						,						_A				:    str=False ):


          '''simple docstring'''


          UpperCAmelCase__			:		Dict													=				BioGptForCausalLM(_A )
          model.to(_A )
          if gradient_checkpointing:
              model.gradient_checkpointing_enable()

          UpperCAmelCase__			:		Tuple													=				model(_A						,						labels=_A )
          self.parent.assertEqual(result.loss.shape						,						() )
          self.parent.assertEqual(result.logits.shape						,						(self.batch_size, self.seq_length, self.vocab_size) )
          result.loss.backward()






      def lowercase_							(					self				:    Union[str, Any]						,						_A				:    int						,						*_A				:    Dict ):


          '''simple docstring'''


          UpperCAmelCase__			:		Any													=				BioGptModel(_A )
          UpperCAmelCase__			:		Any													=				model.config.initializer_range / math.sqrt(2 * model.config.num_hidden_layers )
          for key in model.state_dict().keys():
              if "c_proj" in key and "weight" in key:
                  self.parent.assertLessEqual(abs(torch.std(model.state_dict()[key] ) - model_std )						,						0.0_0_1 )
                  self.parent.assertLessEqual(abs(torch.mean(model.state_dict()[key] ) - 0.0 )						,						0.0_1 )






      def lowercase_							(					self				:    List[Any]						,						_A				:    Union[str, Any]						,						_A				:    Union[str, Any]						,						_A				:    Any						,						_A				:    Union[str, Any]						,						_A				:    List[str]						,						*_A				:    Optional[Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		Union[str, Any]													=				self.num_labels
          UpperCAmelCase__			:		str													=				BioGptForTokenClassification(_A )
          model.to(_A )
          model.eval()
          UpperCAmelCase__			:		Optional[Any]													=				model(_A						,						attention_mask=_A						,						token_type_ids=_A )
          self.parent.assertEqual(result.logits.shape						,						(self.batch_size, self.seq_length, self.num_labels) )






      def lowercase_							(					self				:    Optional[Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		Union[str, Any]													=				self.prepare_config_and_inputs()
          (
              (
              UpperCAmelCase__
          )						,						(
              UpperCAmelCase__
          )						,						(
              UpperCAmelCase__
          )						,						(
              UpperCAmelCase__
          )						,						(
              UpperCAmelCase__
          )						,						(
              UpperCAmelCase__
          )						,						(
              UpperCAmelCase__
          )						,						
          )			:		Optional[Any]													=				config_and_inputs
          UpperCAmelCase__			:		Tuple													=				{'''input_ids''': input_ids, '''attention_mask''': input_mask}
          return config, inputs_dict




@require_torch
class 			lowerCamelCase_   (	__a     ,       __a     ,       __a     ,       unittest.TestCase      ):
      lowerCAmelCase__		     =     (
          (BioGptModel, BioGptForCausalLM, BioGptForSequenceClassification, BioGptForTokenClassification)
          if is_torch_available()
          else ()
      )
      lowerCAmelCase__		     =     (BioGptForCausalLM,) if is_torch_available() else ()
      lowerCAmelCase__		     =     (
          {
              'feature-extraction': BioGptModel,
              'text-classification': BioGptForSequenceClassification,
              'text-generation': BioGptForCausalLM,
              'token-classification': BioGptForTokenClassification,
              'zero-shot': BioGptForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )
      lowerCAmelCase__		     =     False






      def lowercase_							(					self				:    Tuple ):


          '''simple docstring'''


          UpperCAmelCase__			:		List[Any]													=				BioGptModelTester(self )
          UpperCAmelCase__			:		Any													=				ConfigTester(self						,						config_class=_A						,						hidden_size=37 )






      def lowercase_							(					self				:    List[str] ):


          '''simple docstring'''


          self.config_tester.run_common_tests()






      def lowercase_							(					self				:    List[str] ):


          '''simple docstring'''


          UpperCAmelCase__			:		str													=				self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*_A )






      def lowercase_							(					self				:    int ):


          '''simple docstring'''


          UpperCAmelCase__			:		Union[str, Any]													=				self.model_tester.prepare_config_and_inputs()
          for type in ["absolute", "relative_key", "relative_key_query"]:
              UpperCAmelCase__			:		Any													=				type
              self.model_tester.create_and_check_model(*_A )






      def lowercase_							(					self				:    int ):


          '''simple docstring'''


          UpperCAmelCase__			:		Dict													=				self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_biogpt_model_attention_mask_past(*_A )






      def lowercase_							(					self				:    Union[str, Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		Any													=				self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_forward_and_backwards(*_A						,						gradient_checkpointing=_A )






      def lowercase_							(					self				:    Optional[Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		Union[str, Any]													=				self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_biogpt_model_past_large_inputs(*_A )






      def lowercase_							(					self				:    str ):


          '''simple docstring'''


          UpperCAmelCase__			:		int													=				self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_biogpt_weight_initialization(*_A )






      def lowercase_							(					self				:    Optional[Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		int													=				self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_biogpt_for_token_classification(*_A )






      @slow
      def lowercase_							(					self				:    Union[str, Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		List[Any]													=				BioGptForCausalLM.from_pretrained('''microsoft/biogpt''' )
          model.to(_A )
          UpperCAmelCase__			:		Dict													=				BioGptTokenizer.from_pretrained('''microsoft/biogpt''' )

          UpperCAmelCase__			:		str													=				'''left'''

          # Define PAD Token = EOS Token = 50256
          UpperCAmelCase__			:		Tuple													=				tokenizer.eos_token
          UpperCAmelCase__			:		str													=				model.config.eos_token_id

          # use different length sentences to test batching
          UpperCAmelCase__			:		List[str]													=				[
              '''Hello, my dog is a little''',
              '''Today, I''',
          ]

          UpperCAmelCase__			:		List[Any]													=				tokenizer(_A						,						return_tensors='''pt'''						,						padding=_A )
          UpperCAmelCase__			:		Dict													=				inputs['''input_ids'''].to(_A )

          UpperCAmelCase__			:		List[str]													=				model.generate(
              input_ids=_A						,						attention_mask=inputs['''attention_mask'''].to(_A )						,						)

          UpperCAmelCase__			:		List[str]													=				tokenizer(sentences[0]						,						return_tensors='''pt''' ).input_ids.to(_A )
          UpperCAmelCase__			:		List[str]													=				model.generate(input_ids=_A )

          UpperCAmelCase__			:		List[Any]													=				inputs_non_padded.shape[-1] - inputs['''attention_mask'''][-1].long().sum().cpu().item()
          UpperCAmelCase__			:		Optional[Any]													=				tokenizer(sentences[1]						,						return_tensors='''pt''' ).input_ids.to(_A )
          UpperCAmelCase__			:		Optional[Any]													=				model.generate(input_ids=_A						,						max_length=model.config.max_length - num_paddings )

          UpperCAmelCase__			:		List[Any]													=				tokenizer.batch_decode(_A						,						skip_special_tokens=_A )
          UpperCAmelCase__			:		List[str]													=				tokenizer.decode(output_non_padded[0]						,						skip_special_tokens=_A )
          UpperCAmelCase__			:		Tuple													=				tokenizer.decode(output_padded[0]						,						skip_special_tokens=_A )

          UpperCAmelCase__			:		List[str]													=				[
              '''Hello, my dog is a little bit bigger than a little bit.''',
              '''Today, I have a good idea of how to use the information''',
          ]
          self.assertListEqual(_A						,						_A )
          self.assertListEqual(_A						,						[non_padded_sentence, padded_sentence] )






      @slow
      def lowercase_							(					self				:    Tuple ):


          '''simple docstring'''


          for model_name in BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              UpperCAmelCase__			:		str													=				BioGptModel.from_pretrained(_A )
              self.assertIsNotNone(_A )






      def lowercase_							(					self				:    Optional[Any] ):


          '''simple docstring'''


          UpperCAmelCase__						,						UpperCAmelCase__			:		Dict													=				self.model_tester.prepare_config_and_inputs_for_common()
          UpperCAmelCase__			:		Dict													=				3
          UpperCAmelCase__			:		Union[str, Any]													=				input_dict['''input_ids''']
          UpperCAmelCase__			:		Dict													=				input_ids.ne(1 ).to(_A )
          UpperCAmelCase__			:		Optional[int]													=				ids_tensor([self.model_tester.batch_size]						,						self.model_tester.type_sequence_label_size )
          UpperCAmelCase__			:		Optional[Any]													=				BioGptForSequenceClassification(_A )
          model.to(_A )
          model.eval()
          UpperCAmelCase__			:		int													=				model(_A						,						attention_mask=_A						,						labels=_A )
          self.assertEqual(result.logits.shape						,						(self.model_tester.batch_size, self.model_tester.num_labels) )






      def lowercase_							(					self				:    List[Any] ):


          '''simple docstring'''


          UpperCAmelCase__						,						UpperCAmelCase__			:		int													=				self.model_tester.prepare_config_and_inputs_for_common()
          UpperCAmelCase__			:		Optional[Any]													=				3
          UpperCAmelCase__			:		Dict													=				'''multi_label_classification'''
          UpperCAmelCase__			:		str													=				input_dict['''input_ids''']
          UpperCAmelCase__			:		int													=				input_ids.ne(1 ).to(_A )
          UpperCAmelCase__			:		Union[str, Any]													=				ids_tensor(
              [self.model_tester.batch_size, config.num_labels]						,						self.model_tester.type_sequence_label_size ).to(torch.float )
          UpperCAmelCase__			:		List[Any]													=				BioGptForSequenceClassification(_A )
          model.to(_A )
          model.eval()
          UpperCAmelCase__			:		int													=				model(_A						,						attention_mask=_A						,						labels=_A )
          self.assertEqual(result.logits.shape						,						(self.model_tester.batch_size, self.model_tester.num_labels) )




@require_torch
class 			lowerCamelCase_   (	unittest.TestCase      ):






      @slow
      def lowercase_							(					self				:    Tuple ):


          '''simple docstring'''


          UpperCAmelCase__			:		int													=				BioGptForCausalLM.from_pretrained('''microsoft/biogpt''' )
          UpperCAmelCase__			:		Union[str, Any]													=				torch.tensor([[2, 4_805, 9, 656, 21]] )
          UpperCAmelCase__			:		List[Any]													=				model(_A )[0]

          UpperCAmelCase__			:		Tuple													=				42_384

          UpperCAmelCase__			:		Tuple													=				torch.Size((1, 5, vocab_size) )
          self.assertEqual(output.shape						,						_A )

          UpperCAmelCase__			:		int													=				torch.tensor(
              [[[-9.5_2_3_6, -9.8_9_1_8, 1_0.4_5_5_7], [-1_1.0_4_6_9, -9.6_4_2_3, 8.1_0_2_2], [-8.8_6_6_4, -7.8_8_2_6, 5.5_3_2_5]]] )

          self.assertTrue(torch.allclose(output[:, :3, :3]						,						_A						,						atol=1e-4 ) )






      @slow
      def lowercase_							(					self				:    Tuple ):


          '''simple docstring'''


          UpperCAmelCase__			:		int													=				BioGptTokenizer.from_pretrained('''microsoft/biogpt''' )
          UpperCAmelCase__			:		int													=				BioGptForCausalLM.from_pretrained('''microsoft/biogpt''' )
          model.to(_A )

          torch.manual_seed(0 )
          UpperCAmelCase__			:		Dict													=				tokenizer('''COVID-19 is'''						,						return_tensors='''pt''' ).to(_A )
          UpperCAmelCase__			:		List[str]													=				model.generate(
              **_A						,						min_length=100						,						max_length=1_024						,						num_beams=5						,						early_stopping=_A						,						)
          UpperCAmelCase__			:		str													=				tokenizer.decode(output_ids[0]						,						skip_special_tokens=_A )

          UpperCAmelCase__			:		Optional[Any]													=				(
              '''COVID-19 is a global pandemic caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2), the'''
              ''' causative agent of coronavirus disease 2019 (COVID-19), which has spread to more than 200 countries and'''
              ''' territories, including the United States (US), Canada, Australia, New Zealand, the United Kingdom (UK),'''
              ''' and the United States of America (USA), as of March 11, 2020, with more than 800,000 confirmed cases and'''
              ''' more than 800,000 deaths.'''
          )
          self.assertEqual(_A						,						_A )




'''simple docstring'''
from typing import TYPE_CHECKING

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


UpperCamelCase__    					=      {
    '''configuration_distilbert''': [
        '''DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''DistilBertConfig''',
        '''DistilBertOnnxConfig''',
    ],
    '''tokenization_distilbert''': ['''DistilBertTokenizer'''],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      ['''DistilBertTokenizerFast''']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''DistilBertForMaskedLM''',
      '''DistilBertForMultipleChoice''',
      '''DistilBertForQuestionAnswering''',
      '''DistilBertForSequenceClassification''',
      '''DistilBertForTokenClassification''',
      '''DistilBertModel''',
      '''DistilBertPreTrainedModel''',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''TFDistilBertForMaskedLM''',
      '''TFDistilBertForMultipleChoice''',
      '''TFDistilBertForQuestionAnswering''',
      '''TFDistilBertForSequenceClassification''',
      '''TFDistilBertForTokenClassification''',
      '''TFDistilBertMainLayer''',
      '''TFDistilBertModel''',
      '''TFDistilBertPreTrainedModel''',
  ]

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''FlaxDistilBertForMaskedLM''',
      '''FlaxDistilBertForMultipleChoice''',
      '''FlaxDistilBertForQuestionAnswering''',
      '''FlaxDistilBertForSequenceClassification''',
      '''FlaxDistilBertForTokenClassification''',
      '''FlaxDistilBertModel''',
      '''FlaxDistilBertPreTrainedModel''',
  ]


if TYPE_CHECKING:
  from .configuration_distilbert import (
      DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
      DistilBertConfig,
      DistilBertOnnxConfig,
  )
  from .tokenization_distilbert import DistilBertTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_distilbert_fast import DistilBertTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_distilbert import (
        DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        DistilBertForMaskedLM,
        DistilBertForMultipleChoice,
        DistilBertForQuestionAnswering,
        DistilBertForSequenceClassification,
        DistilBertForTokenClassification,
        DistilBertModel,
        DistilBertPreTrainedModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_distilbert import (
        TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFDistilBertForMaskedLM,
        TFDistilBertForMultipleChoice,
        TFDistilBertForQuestionAnswering,
        TFDistilBertForSequenceClassification,
        TFDistilBertForTokenClassification,
        TFDistilBertMainLayer,
        TFDistilBertModel,
        TFDistilBertPreTrainedModel,
    )

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_distilbert import (
        FlaxDistilBertForMaskedLM,
        FlaxDistilBertForMultipleChoice,
        FlaxDistilBertForQuestionAnswering,
        FlaxDistilBertForSequenceClassification,
        FlaxDistilBertForTokenClassification,
        FlaxDistilBertModel,
        FlaxDistilBertPreTrainedModel,
    )

else:
  import sys

  UpperCamelCase__    					=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
