





"""simple docstring"""
from __future__ import annotations

import os
import tempfile
import unittest

from transformers import ConvBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
  import tensorflow as tf

  from transformers import (
      TFConvBertForMaskedLM,
      TFConvBertForMultipleChoice,
      TFConvBertForQuestionAnswering,
      TFConvBertForSequenceClassification,
      TFConvBertForTokenClassification,
      TFConvBertModel,
  )






class 					_SCREAMING_SNAKE_CASE:




       def __init__(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__=13		,SCREAMING_SNAKE_CASE__=7		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=99		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__=2		,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__=5_12		,SCREAMING_SNAKE_CASE__=16		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=4		,SCREAMING_SNAKE_CASE__=None		,)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  parent
             __SCREAMING_SNAKE_CASE   :int						=  13
             __SCREAMING_SNAKE_CASE   :Dict						=  7
             __SCREAMING_SNAKE_CASE   :List[str]						=  True
             __SCREAMING_SNAKE_CASE   :Any						=  True
             __SCREAMING_SNAKE_CASE   :List[Any]						=  True
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  True
             __SCREAMING_SNAKE_CASE   :Tuple						=  99
             __SCREAMING_SNAKE_CASE   :Any						=  3_84
             __SCREAMING_SNAKE_CASE   :Dict						=  2
             __SCREAMING_SNAKE_CASE   :List[str]						=  4
             __SCREAMING_SNAKE_CASE   :Tuple						=  37
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  '''gelu'''
             __SCREAMING_SNAKE_CASE   :str						=  0.1
             __SCREAMING_SNAKE_CASE   :List[Any]						=  0.1
             __SCREAMING_SNAKE_CASE   :Dict						=  5_12
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  16
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  2
             __SCREAMING_SNAKE_CASE   :Tuple						=  0.0_2
             __SCREAMING_SNAKE_CASE   :Tuple						=  3
             __SCREAMING_SNAKE_CASE   :Any						=  4
             __SCREAMING_SNAKE_CASE   :List[Any]						=  1_28
             __SCREAMING_SNAKE_CASE   :List[Any]						=  2
             __SCREAMING_SNAKE_CASE   :Tuple						=  9
             __SCREAMING_SNAKE_CASE   :Dict						=  1
             __SCREAMING_SNAKE_CASE   :Any						=  None




       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  ids_tensor([self.batch_size, self.seq_length]		,self.vocab_size							)

             __SCREAMING_SNAKE_CASE   :List[str]						=  None
             if self.use_input_mask:
                   __SCREAMING_SNAKE_CASE   :Dict						=  random_attention_mask([self.batch_size, self.seq_length]							)

             __SCREAMING_SNAKE_CASE   :List[Any]						=  None
             if self.use_token_type_ids:
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  ids_tensor([self.batch_size, self.seq_length]		,self.type_vocab_size							)

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

             __SCREAMING_SNAKE_CASE   :int						=  ConvBertConfig(
                 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		,initializer_range=self.initializer_range		,return_dict=lowercase_		,)

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




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[str]						=  TFConvBertModel(config=lowercase_							)
             __SCREAMING_SNAKE_CASE   :str						=  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}

             __SCREAMING_SNAKE_CASE   :str						=  [input_ids, input_mask]
             __SCREAMING_SNAKE_CASE   :Tuple						=  model(lowercase_							)

             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(lowercase_							)

             self.parent.assertEqual(result.last_hidden_state.shape		,(self.batch_size, self.seq_length, self.hidden_size)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  TFConvBertForMaskedLM(config=lowercase_							)
             __SCREAMING_SNAKE_CASE   :int						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model(lowercase_							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.seq_length, self.vocab_size)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Union[str, Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.num_labels
             __SCREAMING_SNAKE_CASE   :Any						=  TFConvBertForSequenceClassification(config=lowercase_							)
             __SCREAMING_SNAKE_CASE   :Any						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }

             __SCREAMING_SNAKE_CASE   :List[str]						=  model(lowercase_							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.num_labels)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  self.num_choices
             __SCREAMING_SNAKE_CASE   :Any						=  TFConvBertForMultipleChoice(config=lowercase_							)
             __SCREAMING_SNAKE_CASE   :List[Any]						=  tf.tile(tf.expand_dims(lowercase_		,1							)		,(1, self.num_choices, 1)							)
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  tf.tile(tf.expand_dims(lowercase_		,1							)		,(1, self.num_choices, 1)							)
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  tf.tile(tf.expand_dims(lowercase_		,1							)		,(1, self.num_choices, 1)							)
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  {
                 '''input_ids''': multiple_choice_inputs_ids,
                 '''attention_mask''': multiple_choice_input_mask,
                 '''token_type_ids''': multiple_choice_token_type_ids,
             }
             __SCREAMING_SNAKE_CASE   :Tuple						=  model(lowercase_							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.num_choices)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  self.num_labels
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  TFConvBertForTokenClassification(config=lowercase_							)
             __SCREAMING_SNAKE_CASE   :Any						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model(lowercase_							)
             self.parent.assertEqual(result.logits.shape		,(self.batch_size, self.seq_length, self.num_labels)							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  TFConvBertForQuestionAnswering(config=lowercase_							)
             __SCREAMING_SNAKE_CASE   :Dict						=  {
                 '''input_ids''': input_ids,
                 '''attention_mask''': input_mask,
                 '''token_type_ids''': token_type_ids,
             }

             __SCREAMING_SNAKE_CASE   :Any						=  model(lowercase_							)
             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     _UpperCamelCase     (						self							)			->      Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  self.prepare_config_and_inputs()
             (
                 (
                 __SCREAMING_SNAKE_CASE						
             )				,(
                 __SCREAMING_SNAKE_CASE						
             )				,(
                 __SCREAMING_SNAKE_CASE						
             )				,(
                 __SCREAMING_SNAKE_CASE						
             )				,(
                 __SCREAMING_SNAKE_CASE						
             )				,(
                 __SCREAMING_SNAKE_CASE						
             )				,(
                 __SCREAMING_SNAKE_CASE						
             )				,						
             )   :List[str]						=  config_and_inputs
             __SCREAMING_SNAKE_CASE   :List[Any]						=  {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
             return config, inputs_dict






@require_tf
class 					_SCREAMING_SNAKE_CASE(   _UpperCAmelCase    ,	_UpperCAmelCase    ,	unittest.TestCase  ):
       SCREAMING_SNAKE_CASE_   :      Dict							=  (
           (
               TFConvBertModel,
               TFConvBertForMaskedLM,
               TFConvBertForQuestionAnswering,
               TFConvBertForSequenceClassification,
               TFConvBertForTokenClassification,
               TFConvBertForMultipleChoice,
           )
           if is_tf_available()
           else ()
       )
       SCREAMING_SNAKE_CASE_   :      Optional[int]							=  (
           {
               '''feature-extraction''': TFConvBertModel,
               '''fill-mask''': TFConvBertForMaskedLM,
               '''question-answering''': TFConvBertForQuestionAnswering,
               '''text-classification''': TFConvBertForSequenceClassification,
               '''token-classification''': TFConvBertForTokenClassification,
               '''zero-shot''': TFConvBertForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )
       SCREAMING_SNAKE_CASE_   :      Dict							=  False
       SCREAMING_SNAKE_CASE_   :      List[str]							=  False
       SCREAMING_SNAKE_CASE_   :      Union[str, Any]							=  False




       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  TFConvBertModelTester(self							)
             __SCREAMING_SNAKE_CASE   :List[Any]						=  ConfigTester(self		,config_class=lowercase_		,hidden_size=37							)




       def     _UpperCamelCase     (						self							)			->      List[str]:





             """simple docstring"""






             self.config_tester.run_common_tests()




       def     _UpperCamelCase     (						self							)			->      Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Any						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(*lowercase_							)




       def     _UpperCamelCase     (						self							)			->      int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[str]						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_masked_lm(*lowercase_							)




       def     _UpperCamelCase     (						self							)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_multiple_choice(*lowercase_							)




       def     _UpperCamelCase     (						self							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[Any]						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_question_answering(*lowercase_							)




       def     _UpperCamelCase     (						self							)			->      List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_sequence_classification(*lowercase_							)




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_token_classification(*lowercase_							)




       @slow
       def     _UpperCamelCase     (						self							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :List[str]						=  self.model_tester.prepare_config_and_inputs_for_common()
             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  True
             __SCREAMING_SNAKE_CASE   :str						=  True

             if hasattr(lowercase_		,'''use_cache'''							):
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  True

             __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  getattr(self.model_tester		,'''encoder_seq_length'''		,self.model_tester.seq_length							)
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  getattr(self.model_tester		,'''key_length'''		,lowercase_							)

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE   :List[str]						=  self._prepare_for_class(lowercase_		,lowercase_							)
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model_class(lowercase_							)
                   __SCREAMING_SNAKE_CASE   :Tuple						=  len(model(lowercase_							)							)

                   with tempfile.TemporaryDirectory() as tmpdirname:
                         model.save_pretrained(lowercase_		,saved_model=lowercase_							)
                         __SCREAMING_SNAKE_CASE   :Optional[int]						=  os.path.join(lowercase_		,'''saved_model'''		,'''1'''							)
                         __SCREAMING_SNAKE_CASE   :Dict						=  tf.keras.models.load_model(lowercase_							)
                         __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(lowercase_							)

                         if self.is_encoder_decoder:
                               __SCREAMING_SNAKE_CASE   :Optional[int]						=  outputs['''encoder_hidden_states''']
                               __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  outputs['''encoder_attentions''']
                         else:
                               __SCREAMING_SNAKE_CASE   :Dict						=  outputs['''hidden_states''']
                               __SCREAMING_SNAKE_CASE   :Optional[Any]						=  outputs['''attentions''']

                         self.assertEqual(len(lowercase_							)		,lowercase_							)

                         __SCREAMING_SNAKE_CASE   :Any						=  getattr(
                             self.model_tester		,'''expected_num_hidden_layers'''		,self.model_tester.num_hidden_layers + 1							)

                         self.assertEqual(len(lowercase_							)		,lowercase_							)
                         self.assertListEqual(
                             list(output_hidden_states[0].shape[-2:]							)		,[self.model_tester.seq_length, self.model_tester.hidden_size]		,)

                         self.assertEqual(len(lowercase_							)		,self.model_tester.num_hidden_layers							)
                         self.assertListEqual(
                             list(output_attentions[0].shape[-3:]							)		,[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]		,)




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Dict						=  TFConvBertModel.from_pretrained('''YituTech/conv-bert-base'''							)
             self.assertIsNotNone(lowercase_							)




       def     _UpperCamelCase     (						self							)			->      str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :Optional[int]						=  self.model_tester.prepare_config_and_inputs_for_common()
             __SCREAMING_SNAKE_CASE   :int						=  True
             __SCREAMING_SNAKE_CASE   :Dict						=  getattr(self.model_tester		,'''decoder_seq_length'''		,self.model_tester.seq_length							)
             __SCREAMING_SNAKE_CASE   :Dict						=  getattr(self.model_tester		,'''encoder_seq_length'''		,self.model_tester.seq_length							)
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  getattr(self.model_tester		,'''key_length'''		,lowercase_							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  getattr(self.model_tester		,'''key_length'''		,lowercase_							)

             def check_decoder_attentions_output(SCREAMING_SNAKE_CASE__							):
                   __SCREAMING_SNAKE_CASE   :str						=  len(lowercase_							)
                   self.assertEqual(out_len % 2		,0							)
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  outputs.decoder_attentions
                   self.assertEqual(len(lowercase_							)		,self.model_tester.num_hidden_layers							)
                   self.assertListEqual(
                       list(decoder_attentions[0].shape[-3:]							)		,[self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]		,)

             def check_encoder_attentions_output(SCREAMING_SNAKE_CASE__							):
                   __SCREAMING_SNAKE_CASE   :str						=  [
                       t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
                   ]
                   self.assertEqual(len(lowercase_							)		,self.model_tester.num_hidden_layers							)
                   self.assertListEqual(
                       list(attentions[0].shape[-3:]							)		,[self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]		,)

             for model_class in self.all_model_classes:
                   __SCREAMING_SNAKE_CASE   :Dict						=  True
                   __SCREAMING_SNAKE_CASE   :Dict						=  False
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model_class(lowercase_							)
                   __SCREAMING_SNAKE_CASE   :Optional[Any]						=  model(self._prepare_for_class(lowercase_		,lowercase_							)							)
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  len(lowercase_							)
                   self.assertEqual(config.output_hidden_states		,lowercase_							)
                   check_encoder_attentions_output(lowercase_							)

                   if self.is_encoder_decoder:
                         __SCREAMING_SNAKE_CASE   :str						=  model_class(lowercase_							)
                         __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  model(self._prepare_for_class(lowercase_		,lowercase_							)							)
                         self.assertEqual(config.output_hidden_states		,lowercase_							)
                         check_decoder_attentions_output(lowercase_							)

                   # Check that output attentions can also be changed via the config
                   del inputs_dict["output_attentions"]
                   __SCREAMING_SNAKE_CASE   :int						=  True
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  model_class(lowercase_							)
                   __SCREAMING_SNAKE_CASE   :Any						=  model(self._prepare_for_class(lowercase_		,lowercase_							)							)
                   self.assertEqual(config.output_hidden_states		,lowercase_							)
                   check_encoder_attentions_output(lowercase_							)

                   # Check attention is always last and order is fine
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  True
                   __SCREAMING_SNAKE_CASE   :int						=  True
                   __SCREAMING_SNAKE_CASE   :Any						=  model_class(lowercase_							)
                   __SCREAMING_SNAKE_CASE   :List[Any]						=  model(self._prepare_for_class(lowercase_		,lowercase_							)							)

                   self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)		,len(lowercase_							)							)
                   self.assertEqual(model.config.output_hidden_states		,lowercase_							)
                   check_encoder_attentions_output(lowercase_							)






@require_tf
class 					_SCREAMING_SNAKE_CASE(   unittest.TestCase  ):




       @slow
       def     _UpperCamelCase     (						self							)			->      str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :int						=  TFConvBertModel.from_pretrained('''YituTech/conv-bert-base'''							)
             __SCREAMING_SNAKE_CASE   :Dict						=  tf.constant([[0, 1, 2, 3, 4, 5]]							)
             __SCREAMING_SNAKE_CASE   :List[Any]						=  model(lowercase_							)[0]

             __SCREAMING_SNAKE_CASE   :str						=  [1, 6, 7_68]
             self.assertEqual(output.shape		,lowercase_							)

             __SCREAMING_SNAKE_CASE   :Tuple						=  tf.constant(
                 [
                     [
                         [-0.0_3_4_7_5_4_9_3, -0.4_6_8_6_0_3_4, -0.3_0_6_3_8_8_3_2],
                         [0.2_2_6_3_7_2_4_8, -0.2_6_9_8_8_6_4_6, -0.7_4_2_3_4_2_4],
                         [0.1_0_3_2_4_8_6_8, -0.4_5_0_1_3_5_0_8, -0.5_8_2_8_0_7_8_4],
                     ]
                 ]							)
             tf.debugging.assert_near(output[:, :3, :3]		,lowercase_		,atol=1E-4							)


import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available
from . import BaseDiffusersCLICommand
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	Union[str, Any]      )							->      Union[str, Any]:





    '''simple docstring'''






    return EnvironmentCommand()


class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    @staticmethod
    def 						snake_case__     (      lowercase_ :       ArgumentParser		)->    Dict:





        '''simple docstring'''







        A__          =   parser.add_parser('env'		)
        download_parser.set_defaults(func=lowercase_		)


    def 						snake_case__     (      self :       List[Any]		)->    List[str]:





        '''simple docstring'''







        A__          =   huggingface_hub.__version__

        A__          =   'not installed'
        A__          =   'NA'
        if is_torch_available():
            import torch

            A__          =   torch.__version__
            A__          =   torch.cuda.is_available()

        A__          =   'not installed'
        if is_transformers_available():
            import transformers

            A__          =   transformers.__version__

        A__          =   'not installed'
        if is_accelerate_available():
            import accelerate

            A__          =   accelerate.__version__

        A__          =   'not installed'
        if is_xformers_available():
            import xformers

            A__          =   xformers.__version__

        A__          =   {
            '`diffusers` version': version,
            'Platform': platform.platform(),
            'Python version': platform.python_version(),
            'PyTorch version (GPU?)': F'{pt_version} ({pt_cuda_available})',
            'Huggingface_hub version': hub_version,
            'Transformers version': transformers_version,
            'Accelerate version': accelerate_version,
            'xFormers version': xformers_version,
            'Using GPU in script?': '<fill in>',
            'Using distributed or parallel set-up in script?': '<fill in>',
        }

        print('\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n'		)
        print(self.format_dict(lowercase_		)		)

        return info


    @staticmethod
    def 						snake_case__     (      lowercase_ :       int		)->    Optional[Any]:





        '''simple docstring'''







        return "\n".join([F'- {prop}: {val}' for prop, val in d.items()]		) + "\n"

