


'''simple docstring'''






import os
import tempfile
import unittest

from transformers import FlaubertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

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 (
      FlaubertForMultipleChoice,
      FlaubertForQuestionAnswering,
      FlaubertForQuestionAnsweringSimple,
      FlaubertForSequenceClassification,
      FlaubertForTokenClassification,
      FlaubertModel,
      FlaubertWithLMHeadModel,
  )
  from transformers.models.flaubert.modeling_flaubert import FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST






class    __snake_case       (   _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    def __init__(   self    :  List[Any]    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  Tuple=13    ,						lowerCamelCase    :  Optional[int]=7    ,						lowerCamelCase    :  Any=True    ,						lowerCamelCase    :  List[Any]=True    ,						lowerCamelCase    :  Optional[Any]=True    ,						lowerCamelCase    :  Union[str, Any]=True    ,						lowerCamelCase    :  Dict=True    ,						lowerCamelCase    :  List[str]=False    ,						lowerCamelCase    :  List[str]=False    ,						lowerCamelCase    :  Optional[Any]=False    ,						lowerCamelCase    :  int=2    ,						lowerCamelCase    :  Dict=99    ,						lowerCamelCase    :  Union[str, Any]=0    ,						lowerCamelCase    :  Union[str, Any]=32    ,						lowerCamelCase    :  Dict=5    ,						lowerCamelCase    :  Dict=4    ,						lowerCamelCase    :  List[str]=0.1    ,						lowerCamelCase    :  Optional[Any]=0.1    ,						lowerCamelCase    :  int=5_12    ,						lowerCamelCase    :  List[Any]=12    ,						lowerCamelCase    :  Optional[int]=2    ,						lowerCamelCase    :  List[Any]=0.02    ,						lowerCamelCase    :  int=3    ,						lowerCamelCase    :  Dict=4    ,						lowerCamelCase    :  int="last"    ,						lowerCamelCase    :  Dict=None    ,						lowerCamelCase    :  Union[str, Any]=None    ,						)   ->  List[str]:
      lowerCAmelCase_			:      Dict			=   parent
      lowerCAmelCase_			:      Optional[Any]			=   batch_size
      lowerCAmelCase_			:      Any			=   seq_length
      lowerCAmelCase_			:      Dict			=   is_training
      lowerCAmelCase_			:      List[Any]			=   use_input_lengths
      lowerCAmelCase_			:      Dict			=   use_token_type_ids
      lowerCAmelCase_			:      Union[str, Any]			=   use_labels
      lowerCAmelCase_			:      Optional[Any]			=   gelu_activation
      lowerCAmelCase_			:      str			=   sinusoidal_embeddings
      lowerCAmelCase_			:      Optional[Any]			=   causal
      lowerCAmelCase_			:      List[str]			=   asm
      lowerCAmelCase_			:      Dict			=   n_langs
      lowerCAmelCase_			:      int			=   vocab_size
      lowerCAmelCase_			:      Tuple			=   n_special
      lowerCAmelCase_			:      str			=   hidden_size
      lowerCAmelCase_			:      Tuple			=   num_hidden_layers
      lowerCAmelCase_			:      List[Any]			=   num_attention_heads
      lowerCAmelCase_			:      str			=   hidden_dropout_prob
      lowerCAmelCase_			:      Dict			=   attention_probs_dropout_prob
      lowerCAmelCase_			:      Optional[Any]			=   max_position_embeddings
      lowerCAmelCase_			:      Union[str, Any]			=   type_vocab_size
      lowerCAmelCase_			:      int			=   type_sequence_label_size
      lowerCAmelCase_			:      Optional[int]			=   initializer_range
      lowerCAmelCase_			:      Any			=   num_labels
      lowerCAmelCase_			:      Tuple			=   num_choices
      lowerCAmelCase_			:      List[Any]			=   summary_type
      lowerCAmelCase_			:      Tuple			=   use_proj
      lowerCAmelCase_			:      Tuple			=   scope

    def __lowercase   (   self    :  Dict		)   ->  List[str]:
      lowerCAmelCase_			:      Dict			=   ids_tensor([self.batch_size, self.seq_length]    ,						self.vocab_size		)
      lowerCAmelCase_			:      Optional[int]			=   random_attention_mask([self.batch_size, self.seq_length]		)

      lowerCAmelCase_			:      List[Any]			=   None
      if self.use_input_lengths:
        lowerCAmelCase_			:      Optional[Any]			=   (
            ids_tensor([self.batch_size]    ,						vocab_size=2		) + self.seq_length - 2
        )  # small variation of seq_length

      lowerCAmelCase_			:      Optional[Any]			=   None
      if self.use_token_type_ids:
        lowerCAmelCase_			:      Optional[Any]			=   ids_tensor([self.batch_size, self.seq_length]    ,						self.n_langs		)

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

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

      return (
          config,
          input_ids,
          token_type_ids,
          input_lengths,
          sequence_labels,
          token_labels,
          is_impossible_labels,
          choice_labels,
          input_mask,
      )

    def __lowercase   (   self    :  List[str]		)   ->  Optional[Any]:
      return FlaubertConfig(
          vocab_size=self.vocab_size    ,						n_special=self.n_special    ,						emb_dim=self.hidden_size    ,						n_layers=self.num_hidden_layers    ,						n_heads=self.num_attention_heads    ,						dropout=self.hidden_dropout_prob    ,						attention_dropout=self.attention_probs_dropout_prob    ,						gelu_activation=self.gelu_activation    ,						sinusoidal_embeddings=self.sinusoidal_embeddings    ,						asm=self.asm    ,						causal=self.causal    ,						n_langs=self.n_langs    ,						max_position_embeddings=self.max_position_embeddings    ,						initializer_range=self.initializer_range    ,						summary_type=self.summary_type    ,						use_proj=self.use_proj    ,						)

    def __lowercase   (   self    :  int    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  Any    ,						lowerCamelCase    :  Optional[Any]    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  Tuple    ,						lowerCamelCase    :  Tuple    ,						)   ->  Any:
      lowerCAmelCase_			:      Dict			=   FlaubertModel(config=lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()
      lowerCAmelCase_			:      List[Any]			=   model(lowerCamelCase    ,						lengths=lowerCamelCase    ,						langs=lowerCamelCase		)
      lowerCAmelCase_			:      Tuple			=   model(lowerCamelCase    ,						langs=lowerCamelCase		)
      lowerCAmelCase_			:      Optional[int]			=   model(lowerCamelCase		)
      self.parent.assertEqual(result.last_hidden_state.shape    ,						(self.batch_size, self.seq_length, self.hidden_size)		)

    def __lowercase   (   self    :  int    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  int    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  List[str]    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  int    ,						lowerCamelCase    :  List[str]    ,						lowerCamelCase    :  List[Any]    ,						)   ->  Dict:
      lowerCAmelCase_			:      List[Any]			=   FlaubertWithLMHeadModel(lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()

      lowerCAmelCase_			:      Optional[Any]			=   model(lowerCamelCase    ,						token_type_ids=lowerCamelCase    ,						labels=lowerCamelCase		)
      self.parent.assertEqual(result.loss.shape    ,						()		)
      self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.seq_length, self.vocab_size)		)

    def __lowercase   (   self    :  List[str]    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  Tuple    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  List[Any]    ,						lowerCamelCase    :  List[str]    ,						lowerCamelCase    :  List[Any]    ,						lowerCamelCase    :  Any    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  List[Any]    ,						)   ->  List[Any]:
      lowerCAmelCase_			:      Any			=   FlaubertForQuestionAnsweringSimple(lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()

      lowerCAmelCase_			:      List[Any]			=   model(lowerCamelCase		)

      lowerCAmelCase_			:      Dict			=   model(lowerCamelCase    ,						start_positions=lowerCamelCase    ,						end_positions=lowerCamelCase		)
      self.parent.assertEqual(result.start_logits.shape    ,						(self.batch_size, self.seq_length)		)
      self.parent.assertEqual(result.end_logits.shape    ,						(self.batch_size, self.seq_length)		)

    def __lowercase   (   self    :  Any    ,						lowerCamelCase    :  List[Any]    ,						lowerCamelCase    :  Tuple    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  int    ,						lowerCamelCase    :  List[str]    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  Optional[Any]    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  str    ,						)   ->  Optional[Any]:
      lowerCAmelCase_			:      Dict			=   FlaubertForQuestionAnswering(lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()

      lowerCAmelCase_			:      Optional[int]			=   model(lowerCamelCase		)

      lowerCAmelCase_			:      int			=   model(
          lowerCamelCase    ,						start_positions=lowerCamelCase    ,						end_positions=lowerCamelCase    ,						cls_index=lowerCamelCase    ,						is_impossible=lowerCamelCase    ,						p_mask=lowerCamelCase    ,						)

      lowerCAmelCase_			:      str			=   model(
          lowerCamelCase    ,						start_positions=lowerCamelCase    ,						end_positions=lowerCamelCase    ,						cls_index=lowerCamelCase    ,						is_impossible=lowerCamelCase    ,						)

      ((lowerCAmelCase_),							)			:      Optional[Any]			=   result_with_labels.to_tuple()

      lowerCAmelCase_			:      List[str]			=   model(lowerCamelCase    ,						start_positions=lowerCamelCase    ,						end_positions=lowerCamelCase		)

      ((lowerCAmelCase_),							)			:      Any			=   result_with_labels.to_tuple()

      self.parent.assertEqual(result_with_labels.loss.shape    ,						()		)
      self.parent.assertEqual(result.start_top_log_probs.shape    ,						(self.batch_size, model.config.start_n_top)		)
      self.parent.assertEqual(result.start_top_index.shape    ,						(self.batch_size, model.config.start_n_top)		)
      self.parent.assertEqual(
          result.end_top_log_probs.shape    ,						(self.batch_size, model.config.start_n_top * model.config.end_n_top)		)
      self.parent.assertEqual(
          result.end_top_index.shape    ,						(self.batch_size, model.config.start_n_top * model.config.end_n_top)		)
      self.parent.assertEqual(result.cls_logits.shape    ,						(self.batch_size,)		)

    def __lowercase   (   self    :  int    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  Optional[Any]    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  Tuple    ,						)   ->  Dict:
      lowerCAmelCase_			:      Dict			=   FlaubertForSequenceClassification(lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()

      lowerCAmelCase_			:      Tuple			=   model(lowerCamelCase		)
      lowerCAmelCase_			:      Dict			=   model(lowerCamelCase    ,						labels=lowerCamelCase		)

      self.parent.assertEqual(result.loss.shape    ,						()		)
      self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.type_sequence_label_size)		)

    def __lowercase   (   self    :  int    ,						lowerCamelCase    :  List[str]    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  int    ,						lowerCamelCase    :  Any    ,						lowerCamelCase    :  Tuple    ,						lowerCamelCase    :  Optional[int]    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  Any    ,						)   ->  Tuple:
      lowerCAmelCase_			:      Optional[Any]			=   self.num_labels
      lowerCAmelCase_			:      Union[str, Any]			=   FlaubertForTokenClassification(lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()

      lowerCAmelCase_			:      Dict			=   model(lowerCamelCase    ,						attention_mask=lowerCamelCase    ,						labels=lowerCamelCase		)
      self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.seq_length, self.num_labels)		)

    def __lowercase   (   self    :  Dict    ,						lowerCamelCase    :  List[Any]    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  List[str]    ,						lowerCamelCase    :  Any    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  str    ,						lowerCamelCase    :  Union[str, Any]    ,						)   ->  List[Any]:
      lowerCAmelCase_			:      Any			=   self.num_choices
      lowerCAmelCase_			:      List[Any]			=   FlaubertForMultipleChoice(config=lowerCamelCase		)
      model.to(lowerCamelCase		)
      model.eval()
      lowerCAmelCase_			:      List[str]			=   input_ids.unsqueeze(1		).expand(-1    ,						self.num_choices    ,						-1		).contiguous()
      lowerCAmelCase_			:      Tuple			=   token_type_ids.unsqueeze(1		).expand(-1    ,						self.num_choices    ,						-1		).contiguous()
      lowerCAmelCase_			:      List[Any]			=   input_mask.unsqueeze(1		).expand(-1    ,						self.num_choices    ,						-1		).contiguous()
      lowerCAmelCase_			:      List[str]			=   model(
          lowerCamelCase    ,						attention_mask=lowerCamelCase    ,						token_type_ids=lowerCamelCase    ,						labels=lowerCamelCase    ,						)
      self.parent.assertEqual(result.logits.shape    ,						(self.batch_size, self.num_choices)		)





    def __lowercase   (   self    :  Dict		)   ->  Any:
      lowerCAmelCase_			:      Union[str, Any]			=   self.prepare_config_and_inputs()
      (
          (
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							(
          lowerCAmelCase_
      ),							
      )			:      Union[str, Any]			=   config_and_inputs
      lowerCAmelCase_			:      Any			=   {
          """input_ids""": input_ids,
          """token_type_ids""": token_type_ids,
          """lengths""": input_lengths,
          """attention_mask""": input_mask,
      }
      return config, inputs_dict







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







    """simple docstring"""



    lowercase    =					(
        (
            FlaubertModel,
            FlaubertWithLMHeadModel,
            FlaubertForQuestionAnswering,
            FlaubertForQuestionAnsweringSimple,
            FlaubertForSequenceClassification,
            FlaubertForTokenClassification,
            FlaubertForMultipleChoice,
        )
        if is_torch_available()
        else ()
    )
    lowercase    =					(
        {
            'feature-extraction': FlaubertModel,
            'fill-mask': FlaubertWithLMHeadModel,
            'question-answering': FlaubertForQuestionAnsweringSimple,
            'text-classification': FlaubertForSequenceClassification,
            'token-classification': FlaubertForTokenClassification,
            'zero-shot': FlaubertForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )

    def __lowercase   (   self    :  str    ,						lowerCamelCase    :  Tuple    ,						lowerCamelCase    :  Union[str, Any]    ,						lowerCamelCase    :  Dict    ,						lowerCamelCase    :  Optional[Any]    ,						lowerCamelCase    :  List[str]		)   ->  List[Any]:
      if (
          pipeline_test_casse_name == "QAPipelineTests"
          and tokenizer_name is not None
          and not tokenizer_name.endswith("""Fast"""		)
      ):
        # `QAPipelineTests` fails for a few models when the slower tokenizer are used.
        # (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
        # TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
        return True

      return False

    def __lowercase   (   self    :  Union[str, Any]    ,						lowerCamelCase    :  List[Any]    ,						lowerCamelCase    :  List[Any]    ,						lowerCamelCase    :  List[str]=False		)   ->  Tuple:
      lowerCAmelCase_			:      int			=   super()._prepare_for_class(lowerCamelCase    ,						lowerCamelCase    ,						return_labels=lowerCamelCase		)

      if return_labels:
        if model_class.__name__ == "FlaubertForQuestionAnswering":
          lowerCAmelCase_			:      Optional[Any]			=   torch.zeros(
              self.model_tester.batch_size    ,						dtype=torch.long    ,						device=lowerCamelCase		)
          lowerCAmelCase_			:      Any			=   torch.zeros(
              self.model_tester.batch_size    ,						dtype=torch.long    ,						device=lowerCamelCase		)

      return inputs_dict

    def __lowercase   (   self    :  List[Any]		)   ->  List[Any]:
      lowerCAmelCase_			:      int			=   FlaubertModelTester(self		)
      lowerCAmelCase_			:      Optional[int]			=   ConfigTester(self    ,						config_class=lowerCamelCase    ,						emb_dim=37		)

    def __lowercase   (   self    :  Union[str, Any]		)   ->  str:
      self.config_tester.run_common_tests()

    def __lowercase   (   self    :  int		)   ->  Tuple:
      lowerCAmelCase_			:      Any			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_model(*lowerCamelCase		)

    def __lowercase   (   self    :  List[str]		)   ->  Any:
      lowerCAmelCase_			:      str			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_lm_head(*lowerCamelCase		)

    def __lowercase   (   self    :  Dict		)   ->  Optional[int]:
      lowerCAmelCase_			:      str			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_simple_qa(*lowerCamelCase		)

    def __lowercase   (   self    :  Union[str, Any]		)   ->  str:
      lowerCAmelCase_			:      Tuple			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_qa(*lowerCamelCase		)

    def __lowercase   (   self    :  List[str]		)   ->  Any:
      lowerCAmelCase_			:      List[Any]			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_sequence_classif(*lowerCamelCase		)

    def __lowercase   (   self    :  Optional[int]		)   ->  Union[str, Any]:
      lowerCAmelCase_			:      List[Any]			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_token_classif(*lowerCamelCase		)

    def __lowercase   (   self    :  Dict		)   ->  List[str]:
      lowerCAmelCase_			:      str			=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_flaubert_multiple_choice(*lowerCamelCase		)

    @slow
    def __lowercase   (   self    :  List[str]		)   ->  str:
      for model_name in FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        lowerCAmelCase_			:      List[Any]			=   FlaubertModel.from_pretrained(lowerCamelCase		)
        self.assertIsNotNone(lowerCamelCase		)





    @slow
    @require_torch_gpu
    def __lowercase   (   self    :  Any		)   ->  int:
      lowerCAmelCase_,							lowerCAmelCase_			:      Optional[int]			=   self.model_tester.prepare_config_and_inputs_for_common()
      for model_class in self.all_model_classes:
        # FlauBertForMultipleChoice behaves incorrectly in JIT environments.
        if model_class == FlaubertForMultipleChoice:
          return

        lowerCAmelCase_			:      Tuple			=   True
        lowerCAmelCase_			:      str			=   model_class(config=lowerCamelCase		)

        lowerCAmelCase_			:      Union[str, Any]			=   self._prepare_for_class(lowerCamelCase    ,						lowerCamelCase		)
        lowerCAmelCase_			:      Tuple			=   torch.jit.trace(
            lowerCamelCase    ,						(inputs_dict["""input_ids"""].to("""cpu"""		), inputs_dict["""attention_mask"""].to("""cpu"""		))		)

        with tempfile.TemporaryDirectory() as tmp:
          torch.jit.save(lowerCamelCase    ,						os.path.join(lowerCamelCase    ,						"""traced_model.pt"""		)		)
          lowerCAmelCase_			:      Optional[int]			=   torch.jit.load(os.path.join(lowerCamelCase    ,						"""traced_model.pt"""		)    ,						map_location=lowerCamelCase		)
          loaded(inputs_dict["""input_ids"""].to(lowerCamelCase		)    ,						inputs_dict["""attention_mask"""].to(lowerCamelCase		)		)







@require_torch
class    __snake_case       (   unittest.TestCase):







    """simple docstring"""



    @slow
    def __lowercase   (   self    :  List[Any]		)   ->  Optional[int]:
      lowerCAmelCase_			:      int			=   FlaubertModel.from_pretrained("""flaubert/flaubert_base_cased"""		)
      lowerCAmelCase_			:      Union[str, Any]			=   torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]		)
      with torch.no_grad():
        lowerCAmelCase_			:      int			=   model(lowerCamelCase		)[0]
      lowerCAmelCase_			:      List[str]			=   torch.Size((1, 11, 7_68)		)
      self.assertEqual(output.shape    ,						lowerCamelCase		)
      lowerCAmelCase_			:      List[str]			=   torch.tensor(
          [[[-2.6_251, -1.4_298, -0.0_227], [-2.8_510, -1.6_387, 0.2_258], [-2.8_114, -1.1_832, -0.3_066]]]		)

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







'''simple docstring'''






# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__A					:  Dict											=      {"configuration_timm_backbone": ["TimmBackboneConfig"]}


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __A					:  str											=      ["TimmBackbone"]


if TYPE_CHECKING:
  from .configuration_timm_backbone import TimmBackboneConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_timm_backbone import TimmBackbone

else:
  import sys

  __A					:  Dict											=      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



