





from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

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 (
          TFFunnelBaseModel,
          TFFunnelForMaskedLM,
          TFFunnelForMultipleChoice,
          TFFunnelForPreTraining,
          TFFunnelForQuestionAnswering,
          TFFunnelForSequenceClassification,
          TFFunnelForTokenClassification,
          TFFunnelModel,
      )

class 		UpperCamelCase__			:



     '''simple docstring'''

     def __init__(							self						:   Optional[int]						,lowerCamelCase__						:   Dict						,lowerCamelCase__						:   Optional[Any]=13						,lowerCamelCase__						:   List[str]=7						,lowerCamelCase__						:   List[Any]=True						,lowerCamelCase__						:   int=True						,lowerCamelCase__						:   List[Any]=True						,lowerCamelCase__						:   Tuple=True						,lowerCamelCase__						:   str=99						,lowerCamelCase__						:   List[Any]=[1, 1, 2]						,lowerCamelCase__						:   Optional[Any]=1						,lowerCamelCase__						:   Tuple=32						,lowerCamelCase__						:   str=4						,lowerCamelCase__						:   Dict=8						,lowerCamelCase__						:   Optional[int]=37						,lowerCamelCase__						:   Optional[Any]="gelu_new"						,lowerCamelCase__						:   int=0.1						,lowerCamelCase__						:   Tuple=0.1						,lowerCamelCase__						:   Any=0.0						,lowerCamelCase__						:   Union[str, Any]=512						,lowerCamelCase__						:   List[str]=3						,lowerCamelCase__						:   Optional[int]=0.02						,lowerCamelCase__						:   Any=3						,lowerCamelCase__						:   Tuple=4						,lowerCamelCase__						:   List[Any]=None						,lowerCamelCase__						:   Union[str, Any]=False						,)					->		Tuple:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						parent
           SCREAMING_SNAKE_CASE		=						batch_size
           SCREAMING_SNAKE_CASE		=						seq_length
           SCREAMING_SNAKE_CASE		=						is_training
           SCREAMING_SNAKE_CASE		=						use_input_mask
           SCREAMING_SNAKE_CASE		=						use_token_type_ids
           SCREAMING_SNAKE_CASE		=						use_labels
           SCREAMING_SNAKE_CASE		=						vocab_size
           SCREAMING_SNAKE_CASE		=						block_sizes
           SCREAMING_SNAKE_CASE		=						num_decoder_layers
           SCREAMING_SNAKE_CASE		=						d_model
           SCREAMING_SNAKE_CASE		=						n_head
           SCREAMING_SNAKE_CASE		=						d_head
           SCREAMING_SNAKE_CASE		=						d_inner
           SCREAMING_SNAKE_CASE		=						hidden_act
           SCREAMING_SNAKE_CASE		=						hidden_dropout
           SCREAMING_SNAKE_CASE		=						attention_dropout
           SCREAMING_SNAKE_CASE		=						activation_dropout
           SCREAMING_SNAKE_CASE		=						max_position_embeddings
           SCREAMING_SNAKE_CASE		=						type_vocab_size
           SCREAMING_SNAKE_CASE		=						2
           SCREAMING_SNAKE_CASE		=						num_labels
           SCREAMING_SNAKE_CASE		=						num_choices
           SCREAMING_SNAKE_CASE		=						scope
           SCREAMING_SNAKE_CASE		=						initializer_std

           # Used in the tests to check the size of the first attention layer
           SCREAMING_SNAKE_CASE		=						n_head
           # Used in the tests to check the size of the first hidden state
           SCREAMING_SNAKE_CASE		=						self.d_model
           # Used in the tests to check the number of output hidden states/attentions
           SCREAMING_SNAKE_CASE		=						sum(self.block_sizes	) + (0 if base else self.num_decoder_layers)
           # FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
           # the last hidden state of the first block (which is the first hidden state of the decoder).
           if not base:
                 SCREAMING_SNAKE_CASE		=						self.num_hidden_layers + 2






     def     SCREAMING_SNAKE_CASE__  (							self						:   Optional[int]	)					->		str:




           '''simple docstring'''


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

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

           SCREAMING_SNAKE_CASE		=						None
           if self.use_token_type_ids:
                 SCREAMING_SNAKE_CASE		=						ids_tensor([self.batch_size, self.seq_length]						,self.type_vocab_size	)

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

           SCREAMING_SNAKE_CASE		=						FunnelConfig(
               vocab_size=self.vocab_size						,block_sizes=self.block_sizes						,num_decoder_layers=self.num_decoder_layers						,d_model=self.d_model						,n_head=self.n_head						,d_head=self.d_head						,d_inner=self.d_inner						,hidden_act=self.hidden_act						,hidden_dropout=self.hidden_dropout						,attention_dropout=self.attention_dropout						,activation_dropout=self.activation_dropout						,max_position_embeddings=self.max_position_embeddings						,type_vocab_size=self.type_vocab_size						,initializer_std=self.initializer_std						,)

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






     def     SCREAMING_SNAKE_CASE__  (							self						:   List[Any]						,lowerCamelCase__						:   Union[str, Any]						,lowerCamelCase__						:   Union[str, Any]						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   List[Any]						,lowerCamelCase__						:   Dict						,lowerCamelCase__						:   Tuple						,lowerCamelCase__						:   int						,)					->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelModel(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)

           SCREAMING_SNAKE_CASE		=						[input_ids, input_mask]
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)

           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, self.seq_length, self.d_model)	)

           SCREAMING_SNAKE_CASE		=						False
           SCREAMING_SNAKE_CASE		=						TFFunnelModel(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, self.seq_length, self.d_model)	)

           SCREAMING_SNAKE_CASE		=						False
           SCREAMING_SNAKE_CASE		=						TFFunnelModel(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, self.seq_length, self.d_model)	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Optional[int]						,lowerCamelCase__						:   str						,lowerCamelCase__						:   Tuple						,lowerCamelCase__						:   int						,lowerCamelCase__						:   Optional[Any]						,lowerCamelCase__						:   Optional[Any]						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   List[str]						,)					->		List[Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelBaseModel(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)

           SCREAMING_SNAKE_CASE		=						[input_ids, input_mask]
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)

           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, 2, self.d_model)	)

           SCREAMING_SNAKE_CASE		=						False
           SCREAMING_SNAKE_CASE		=						TFFunnelBaseModel(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, 3, self.d_model)	)

           SCREAMING_SNAKE_CASE		=						False
           SCREAMING_SNAKE_CASE		=						TFFunnelBaseModel(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.last_hidden_state.shape						,(self.batch_size, 2, self.d_model)	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelForPreTraining(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.seq_length)	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelForMaskedLM(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.seq_length, self.vocab_size)	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   List[Any]						,lowerCamelCase__						:   Any						,lowerCamelCase__						:   Dict						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   Optional[int]						,lowerCamelCase__						:   Dict						,lowerCamelCase__						:   Optional[int]						,)					->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.num_labels
           SCREAMING_SNAKE_CASE		=						TFFunnelForSequenceClassification(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.num_labels)	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.num_choices
           SCREAMING_SNAKE_CASE		=						TFFunnelForMultipleChoice(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						tf.tile(tf.expand_dims(lowerCamelCase__						,1	)						,(1, self.num_choices, 1)	)
           SCREAMING_SNAKE_CASE		=						tf.tile(tf.expand_dims(lowerCamelCase__						,1	)						,(1, self.num_choices, 1)	)
           SCREAMING_SNAKE_CASE		=						tf.tile(tf.expand_dims(lowerCamelCase__						,1	)						,(1, self.num_choices, 1)	)
           SCREAMING_SNAKE_CASE		=						{
               """input_ids""": multiple_choice_inputs_ids,
               """attention_mask""": multiple_choice_input_mask,
               """token_type_ids""": multiple_choice_token_type_ids,
           }
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.num_choices)	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Any						,lowerCamelCase__						:   Tuple						,lowerCamelCase__						:   Optional[Any]						,lowerCamelCase__						:   Dict						,lowerCamelCase__						:   Optional[int]						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   List[Any]						,lowerCamelCase__						:   List[Any]						,)					->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.num_labels
           SCREAMING_SNAKE_CASE		=						TFFunnelForTokenClassification(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(lowerCamelCase__	)
           self.parent.assertEqual(result.logits.shape						,(self.batch_size, self.seq_length, self.num_labels)	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   List[str]						,lowerCamelCase__						:   int						,lowerCamelCase__						:   Any						,lowerCamelCase__						:   Union[str, Any]						,lowerCamelCase__						:   Any						,lowerCamelCase__						:   Optional[Any]						,lowerCamelCase__						:   List[Any]						,lowerCamelCase__						:   Union[str, Any]						,)					->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelForQuestionAnswering(config=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
           SCREAMING_SNAKE_CASE		=						model(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     SCREAMING_SNAKE_CASE__  (							self						:   Union[str, Any]	)					->		Union[str, Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						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
           ), 
           )		=						config_and_inputs
           SCREAMING_SNAKE_CASE		=						{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
           return config, inputs_dict

@require_tf
class 		UpperCamelCase__			(				lowerCAmelCase_							,				lowerCAmelCase_							,				unittest.TestCase       ):



     '''simple docstring'''

     __snake_case   :     str		     =      (
         (
             TFFunnelModel,
             TFFunnelForMaskedLM,
             TFFunnelForPreTraining,
             TFFunnelForQuestionAnswering,
             TFFunnelForTokenClassification,
         )
         if is_tf_available()
         else ()
     )
     __snake_case   :     Union[str, Any]		     =      (
         {
             "feature-extraction": (TFFunnelBaseModel, TFFunnelModel),
             "fill-mask": TFFunnelForMaskedLM,
             "question-answering": TFFunnelForQuestionAnswering,
             "text-classification": TFFunnelForSequenceClassification,
             "token-classification": TFFunnelForTokenClassification,
             "zero-shot": TFFunnelForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )
     __snake_case   :     Any		     =      False
     __snake_case   :     Any		     =      False






     def     SCREAMING_SNAKE_CASE__  (							self						:   Any	)					->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelModelTester(self	)
           SCREAMING_SNAKE_CASE		=						ConfigTester(self						,config_class=lowerCamelCase__	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple	)					->		List[str]:




           '''simple docstring'''


           self.config_tester.run_common_tests()






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*lowerCamelCase__	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple	)					->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_pretraining(*lowerCamelCase__	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple	)					->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase__	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Dict	)					->		Tuple:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_token_classification(*lowerCamelCase__	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_question_answering(*lowerCamelCase__	)

@require_tf
class 		UpperCamelCase__			(				lowerCAmelCase_							,				unittest.TestCase       ):



     '''simple docstring'''

     __snake_case   :     Tuple		     =      (
         (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
     )
     __snake_case   :     List[Any]		     =      False
     __snake_case   :     str		     =      False






     def     SCREAMING_SNAKE_CASE__  (							self						:   int	)					->		Any:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						TFFunnelModelTester(self						,base=lowerCamelCase__	)
           SCREAMING_SNAKE_CASE		=						ConfigTester(self						,config_class=lowerCamelCase__	)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Dict	)					->		str:




           '''simple docstring'''


           self.config_tester.run_common_tests()






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_base_model(*lowerCamelCase__	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase__	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_multiple_choice(*lowerCamelCase__	)









import unittest

import numpy as np

from transformers.file_utils import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
      import torch

if is_vision_available():
      from PIL import Image

      from transformers import DPTImageProcessor

class 		UpperCamelCase__			(				unittest.TestCase       ):



     '''simple docstring'''

     def __init__(							self						:   Optional[Any]						,lowerCamelCase__						:   List[str]						,lowerCamelCase__						:   Optional[Any]=7						,lowerCamelCase__						:   Optional[Any]=3						,lowerCamelCase__						:   Union[str, Any]=18						,lowerCamelCase__						:   Optional[int]=30						,lowerCamelCase__						:   int=400						,lowerCamelCase__						:   List[str]=True						,lowerCamelCase__						:   Union[str, Any]=None						,lowerCamelCase__						:   Union[str, Any]=True						,lowerCamelCase__						:   Optional[int]=[0.5, 0.5, 0.5]						,lowerCamelCase__						:   Any=[0.5, 0.5, 0.5]						,)					->		List[str]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						size if size is not None else {"""height""": 18, """width""": 18}
           SCREAMING_SNAKE_CASE		=						parent
           SCREAMING_SNAKE_CASE		=						batch_size
           SCREAMING_SNAKE_CASE		=						num_channels
           SCREAMING_SNAKE_CASE		=						image_size
           SCREAMING_SNAKE_CASE		=						min_resolution
           SCREAMING_SNAKE_CASE		=						max_resolution
           SCREAMING_SNAKE_CASE		=						do_resize
           SCREAMING_SNAKE_CASE		=						size
           SCREAMING_SNAKE_CASE		=						do_normalize
           SCREAMING_SNAKE_CASE		=						image_mean
           SCREAMING_SNAKE_CASE		=						image_std






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




           '''simple docstring'''


           return {
               "image_mean": self.image_mean,
               "image_std": self.image_std,
               "do_normalize": self.do_normalize,
               "do_resize": self.do_resize,
               "size": self.size,
           }

@require_torch
@require_vision
class 		UpperCamelCase__			(				lowerCAmelCase_							,				unittest.TestCase       ):



     '''simple docstring'''

     __snake_case   :     Tuple		     =      DPTImageProcessor if is_vision_available() else None






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						DPTImageProcessingTester(self	)






     @property
     def     SCREAMING_SNAKE_CASE__  (							self						:   Union[str, Any]	)					->		int:




           '''simple docstring'''


           return self.image_processor_tester.prepare_image_processor_dict()






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.image_processing_class(**self.image_processor_dict	)
           self.assertTrue(hasattr(lowerCamelCase__						,"""image_mean"""	)	)
           self.assertTrue(hasattr(lowerCamelCase__						,"""image_std"""	)	)
           self.assertTrue(hasattr(lowerCamelCase__						,"""do_normalize"""	)	)
           self.assertTrue(hasattr(lowerCamelCase__						,"""do_resize"""	)	)
           self.assertTrue(hasattr(lowerCamelCase__						,"""size"""	)	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.image_processing_class.from_dict(self.image_processor_dict	)
           self.assertEqual(image_processor.size						,{"""height""": 18, """width""": 18}	)

           SCREAMING_SNAKE_CASE		=						self.image_processing_class.from_dict(self.image_processor_dict						,size=42	)
           self.assertEqual(image_processor.size						,{"""height""": 42, """width""": 42}	)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.image_processing_class(**self.image_processor_dict	)
           # create random PIL images
           SCREAMING_SNAKE_CASE		=						prepare_image_inputs(self.image_processor_tester						,equal_resolution=lowerCamelCase__	)
           for image in image_inputs:
                 self.assertIsInstance(lowerCamelCase__						,Image.Image	)

           # Test not batched input
           SCREAMING_SNAKE_CASE		=						image_processing(image_inputs[0]						,return_tensors="""pt"""	).pixel_values
           self.assertEqual(
               encoded_images.shape						,(
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )						,)

           # Test batched
           SCREAMING_SNAKE_CASE		=						image_processing(lowerCamelCase__						,return_tensors="""pt"""	).pixel_values
           self.assertEqual(
               encoded_images.shape						,(
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )						,)






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




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.image_processing_class(**self.image_processor_dict	)
           # create random numpy tensors
           SCREAMING_SNAKE_CASE		=						prepare_image_inputs(self.image_processor_tester						,equal_resolution=lowerCamelCase__						,numpify=lowerCamelCase__	)
           for image in image_inputs:
                 self.assertIsInstance(lowerCamelCase__						,np.ndarray	)

           # Test not batched input
           SCREAMING_SNAKE_CASE		=						image_processing(image_inputs[0]						,return_tensors="""pt"""	).pixel_values
           self.assertEqual(
               encoded_images.shape						,(
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )						,)

           # Test batched
           SCREAMING_SNAKE_CASE		=						image_processing(lowerCamelCase__						,return_tensors="""pt"""	).pixel_values
           self.assertEqual(
               encoded_images.shape						,(
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )						,)






     def     SCREAMING_SNAKE_CASE__  (							self						:   Tuple	)					->		Optional[int]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						self.image_processing_class(**self.image_processor_dict	)
           # create random PyTorch tensors
           SCREAMING_SNAKE_CASE		=						prepare_image_inputs(self.image_processor_tester						,equal_resolution=lowerCamelCase__						,torchify=lowerCamelCase__	)
           for image in image_inputs:
                 self.assertIsInstance(lowerCamelCase__						,torch.Tensor	)

           # Test not batched input
           SCREAMING_SNAKE_CASE		=						image_processing(image_inputs[0]						,return_tensors="""pt"""	).pixel_values
           self.assertEqual(
               encoded_images.shape						,(
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )						,)

           # Test batched
           SCREAMING_SNAKE_CASE		=						image_processing(lowerCamelCase__						,return_tensors="""pt"""	).pixel_values
           self.assertEqual(
               encoded_images.shape						,(
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )						,)


