


"""simple docstring"""

from collections import OrderedDict

from ...utils import logging
from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update
from .configuration_auto import CONFIG_MAPPING_NAMES


UpperCAmelCase__  							=logging.get_logger(__name__)


UpperCAmelCase__  							=OrderedDict(
    [
        # Base model mapping
        ("albert", "FlaxAlbertModel"),
        ("bart", "FlaxBartModel"),
        ("beit", "FlaxBeitModel"),
        ("bert", "FlaxBertModel"),
        ("big_bird", "FlaxBigBirdModel"),
        ("blenderbot", "FlaxBlenderbotModel"),
        ("blenderbot-small", "FlaxBlenderbotSmallModel"),
        ("clip", "FlaxCLIPModel"),
        ("distilbert", "FlaxDistilBertModel"),
        ("electra", "FlaxElectraModel"),
        ("gpt-sw3", "FlaxGPT2Model"),
        ("gpt2", "FlaxGPT2Model"),
        ("gpt_neo", "FlaxGPTNeoModel"),
        ("gptj", "FlaxGPTJModel"),
        ("longt5", "FlaxLongT5Model"),
        ("marian", "FlaxMarianModel"),
        ("mbart", "FlaxMBartModel"),
        ("mt5", "FlaxMT5Model"),
        ("opt", "FlaxOPTModel"),
        ("pegasus", "FlaxPegasusModel"),
        ("regnet", "FlaxRegNetModel"),
        ("resnet", "FlaxResNetModel"),
        ("roberta", "FlaxRobertaModel"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormModel"),
        ("roformer", "FlaxRoFormerModel"),
        ("t5", "FlaxT5Model"),
        ("vision-text-dual-encoder", "FlaxVisionTextDualEncoderModel"),
        ("vit", "FlaxViTModel"),
        ("wav2vec2", "FlaxWav2Vec2Model"),
        ("whisper", "FlaxWhisperModel"),
        ("xglm", "FlaxXGLMModel"),
        ("xlm-roberta", "FlaxXLMRobertaModel"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for pre-training mapping
        ("albert", "FlaxAlbertForPreTraining"),
        ("bart", "FlaxBartForConditionalGeneration"),
        ("bert", "FlaxBertForPreTraining"),
        ("big_bird", "FlaxBigBirdForPreTraining"),
        ("electra", "FlaxElectraForPreTraining"),
        ("longt5", "FlaxLongT5ForConditionalGeneration"),
        ("mbart", "FlaxMBartForConditionalGeneration"),
        ("mt5", "FlaxMT5ForConditionalGeneration"),
        ("roberta", "FlaxRobertaForMaskedLM"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForMaskedLM"),
        ("roformer", "FlaxRoFormerForMaskedLM"),
        ("t5", "FlaxT5ForConditionalGeneration"),
        ("wav2vec2", "FlaxWav2Vec2ForPreTraining"),
        ("whisper", "FlaxWhisperForConditionalGeneration"),
        ("xlm-roberta", "FlaxXLMRobertaForMaskedLM"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Masked LM mapping
        ("albert", "FlaxAlbertForMaskedLM"),
        ("bart", "FlaxBartForConditionalGeneration"),
        ("bert", "FlaxBertForMaskedLM"),
        ("big_bird", "FlaxBigBirdForMaskedLM"),
        ("distilbert", "FlaxDistilBertForMaskedLM"),
        ("electra", "FlaxElectraForMaskedLM"),
        ("mbart", "FlaxMBartForConditionalGeneration"),
        ("roberta", "FlaxRobertaForMaskedLM"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForMaskedLM"),
        ("roformer", "FlaxRoFormerForMaskedLM"),
        ("xlm-roberta", "FlaxXLMRobertaForMaskedLM"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Seq2Seq Causal LM mapping
        ("bart", "FlaxBartForConditionalGeneration"),
        ("blenderbot", "FlaxBlenderbotForConditionalGeneration"),
        ("blenderbot-small", "FlaxBlenderbotSmallForConditionalGeneration"),
        ("encoder-decoder", "FlaxEncoderDecoderModel"),
        ("longt5", "FlaxLongT5ForConditionalGeneration"),
        ("marian", "FlaxMarianMTModel"),
        ("mbart", "FlaxMBartForConditionalGeneration"),
        ("mt5", "FlaxMT5ForConditionalGeneration"),
        ("pegasus", "FlaxPegasusForConditionalGeneration"),
        ("t5", "FlaxT5ForConditionalGeneration"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Image-classsification
        ("beit", "FlaxBeitForImageClassification"),
        ("regnet", "FlaxRegNetForImageClassification"),
        ("resnet", "FlaxResNetForImageClassification"),
        ("vit", "FlaxViTForImageClassification"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        ("vision-encoder-decoder", "FlaxVisionEncoderDecoderModel"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Causal LM mapping
        ("bart", "FlaxBartForCausalLM"),
        ("bert", "FlaxBertForCausalLM"),
        ("big_bird", "FlaxBigBirdForCausalLM"),
        ("electra", "FlaxElectraForCausalLM"),
        ("gpt-sw3", "FlaxGPT2LMHeadModel"),
        ("gpt2", "FlaxGPT2LMHeadModel"),
        ("gpt_neo", "FlaxGPTNeoForCausalLM"),
        ("gptj", "FlaxGPTJForCausalLM"),
        ("opt", "FlaxOPTForCausalLM"),
        ("roberta", "FlaxRobertaForCausalLM"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForCausalLM"),
        ("xglm", "FlaxXGLMForCausalLM"),
        ("xlm-roberta", "FlaxXLMRobertaForCausalLM"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Sequence Classification mapping
        ("albert", "FlaxAlbertForSequenceClassification"),
        ("bart", "FlaxBartForSequenceClassification"),
        ("bert", "FlaxBertForSequenceClassification"),
        ("big_bird", "FlaxBigBirdForSequenceClassification"),
        ("distilbert", "FlaxDistilBertForSequenceClassification"),
        ("electra", "FlaxElectraForSequenceClassification"),
        ("mbart", "FlaxMBartForSequenceClassification"),
        ("roberta", "FlaxRobertaForSequenceClassification"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForSequenceClassification"),
        ("roformer", "FlaxRoFormerForSequenceClassification"),
        ("xlm-roberta", "FlaxXLMRobertaForSequenceClassification"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Question Answering mapping
        ("albert", "FlaxAlbertForQuestionAnswering"),
        ("bart", "FlaxBartForQuestionAnswering"),
        ("bert", "FlaxBertForQuestionAnswering"),
        ("big_bird", "FlaxBigBirdForQuestionAnswering"),
        ("distilbert", "FlaxDistilBertForQuestionAnswering"),
        ("electra", "FlaxElectraForQuestionAnswering"),
        ("mbart", "FlaxMBartForQuestionAnswering"),
        ("roberta", "FlaxRobertaForQuestionAnswering"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForQuestionAnswering"),
        ("roformer", "FlaxRoFormerForQuestionAnswering"),
        ("xlm-roberta", "FlaxXLMRobertaForQuestionAnswering"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Token Classification mapping
        ("albert", "FlaxAlbertForTokenClassification"),
        ("bert", "FlaxBertForTokenClassification"),
        ("big_bird", "FlaxBigBirdForTokenClassification"),
        ("distilbert", "FlaxDistilBertForTokenClassification"),
        ("electra", "FlaxElectraForTokenClassification"),
        ("roberta", "FlaxRobertaForTokenClassification"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForTokenClassification"),
        ("roformer", "FlaxRoFormerForTokenClassification"),
        ("xlm-roberta", "FlaxXLMRobertaForTokenClassification"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        # Model for Multiple Choice mapping
        ("albert", "FlaxAlbertForMultipleChoice"),
        ("bert", "FlaxBertForMultipleChoice"),
        ("big_bird", "FlaxBigBirdForMultipleChoice"),
        ("distilbert", "FlaxDistilBertForMultipleChoice"),
        ("electra", "FlaxElectraForMultipleChoice"),
        ("roberta", "FlaxRobertaForMultipleChoice"),
        ("roberta-prelayernorm", "FlaxRobertaPreLayerNormForMultipleChoice"),
        ("roformer", "FlaxRoFormerForMultipleChoice"),
        ("xlm-roberta", "FlaxXLMRobertaForMultipleChoice"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        ("bert", "FlaxBertForNextSentencePrediction"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        ("speech-encoder-decoder", "FlaxSpeechEncoderDecoderModel"),
        ("whisper", "FlaxWhisperForConditionalGeneration"),
    ]
)

UpperCAmelCase__  							=OrderedDict(
    [
        ("whisper", "FlaxWhisperForAudioClassification"),
    ]
)

UpperCAmelCase__  							=_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_MAPPING_NAMES)
UpperCAmelCase__  							=_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_PRETRAINING_MAPPING_NAMES)
UpperCAmelCase__  							=_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_MASKED_LM_MAPPING_NAMES)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES)
UpperCAmelCase__  							=_LazyAutoMapping(CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_CAUSAL_LM_MAPPING_NAMES)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES
)
UpperCAmelCase__  							=_LazyAutoMapping(
    CONFIG_MAPPING_NAMES, FLAX_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES
)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     List[Any]											=		FLAX_MODEL_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModel)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     int											=		FLAX_MODEL_FOR_PRETRAINING_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModelForPreTraining, head_doc="pretraining")





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Tuple											=		FLAX_MODEL_FOR_CAUSAL_LM_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModelForCausalLM, head_doc="causal language modeling")





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     List[str]											=		FLAX_MODEL_FOR_MASKED_LM_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModelForMaskedLM, head_doc="masked language modeling")





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     str											=		FLAX_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING






UpperCAmelCase__  							=auto_class_update(
    FlaxAutoModelForSeqaSeqLM, head_doc="sequence-to-sequence language modeling", checkpoint_for_example="t5-base"
)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     str											=		FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING






UpperCAmelCase__  							=auto_class_update(
    FlaxAutoModelForSequenceClassification, head_doc="sequence classification"
)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Tuple											=		FLAX_MODEL_FOR_QUESTION_ANSWERING_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModelForQuestionAnswering, head_doc="question answering")





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Union[str, Any]											=		FLAX_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING






UpperCAmelCase__  							=auto_class_update(
    FlaxAutoModelForTokenClassification, head_doc="token classification"
)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Optional[Any]											=		FLAX_MODEL_FOR_MULTIPLE_CHOICE_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModelForMultipleChoice, head_doc="multiple choice")





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Optional[int]											=		FLAX_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING






UpperCAmelCase__  							=auto_class_update(
    FlaxAutoModelForNextSentencePrediction, head_doc="next sentence prediction"
)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Union[str, Any]											=		FLAX_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING






UpperCAmelCase__  							=auto_class_update(
    FlaxAutoModelForImageClassification, head_doc="image classification"
)





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     Dict											=		FLAX_MODEL_FOR_VISION_2_SEQ_MAPPING






UpperCAmelCase__  							=auto_class_update(FlaxAutoModelForVisionaSeq, head_doc="vision-to-text modeling")





class    lowerCamelCase__						(		_BaseAutoModelClass    ):
						a :     List[str]											=		FLAX_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING






UpperCAmelCase__  							=auto_class_update(
    FlaxAutoModelForSpeechSeqaSeq, head_doc="sequence-to-sequence speech-to-text modeling"
)




"""simple docstring"""

import unittest

import numpy as np

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

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
       import torch

if is_vision_available():
       from PIL import Image

       from transformers import ChineseCLIPImageProcessor





class    lowerCamelCase__						(		unittest.TestCase    ):
      def __init__(		self	:	List[Any]      ,       A_	:	List[str]      ,       A_	:	str=7      ,       A_	:	Optional[int]=3      ,       A_	:	str=1_8      ,       A_	:	Tuple=3_0      ,       A_	:	Optional[Any]=4_0_0      ,       A_	:	Union[str, Any]=True      ,       A_	:	str=None      ,       A_	:	str=True      ,       A_	:	Optional[Any]=None      ,       A_	:	List[Any]=True      ,       A_	:	Union[str, Any]=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]      ,       A_	:	str=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]      ,       A_	:	List[str]=True      ,       ):






       '''simple docstring'''


       __lowercase									=	size if size is not None else {"""height""": 2_2_4, """width""": 2_2_4}
       __lowercase									=	crop_size if crop_size is not None else {"""height""": 1_8, """width""": 1_8}
       __lowercase									=	parent
       __lowercase									=	batch_size
       __lowercase									=	num_channels
       __lowercase									=	image_size
       __lowercase									=	min_resolution
       __lowercase									=	max_resolution
       __lowercase									=	do_resize
       __lowercase									=	size
       __lowercase									=	do_center_crop
       __lowercase									=	crop_size
       __lowercase									=	do_normalize
       __lowercase									=	image_mean
       __lowercase									=	image_std
       __lowercase									=	do_convert_rgb
      def SCREAMING_SNAKE_CASE_	(		self	:	List[Any]							):






       '''simple docstring'''


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






      def SCREAMING_SNAKE_CASE_	(		self	:	str      ,       A_	:	List[Any]=False      ,       A_	:	List[Any]=False      ,       A_	:	Optional[Any]=False							):






       '''simple docstring'''


       assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

       if equal_resolution:
        __lowercase									=	[]
        for i in range(self.batch_size							):
         image_inputs.append(
             np.random.randint(
                 2_5_5      ,       size=(self.num_channels, self.max_resolution, self.max_resolution)      ,       dtype=np.uinta							)							)
       else:
        __lowercase									=	[]
        for i in range(self.batch_size							):
         __lowercase							,		__lowercase									=	np.random.choice(np.arange(self.min_resolution      ,       self.max_resolution							)      ,       2							)
         image_inputs.append(np.random.randint(2_5_5      ,       size=(self.num_channels, width, height)      ,       dtype=np.uinta							)							)

       if not numpify and not torchify:
        # PIL expects the channel dimension as last dimension
        __lowercase									=	[Image.fromarray(np.moveaxis(A_      ,       0      ,       -1							)							) for x in image_inputs]

       if torchify:
        __lowercase									=	[torch.from_numpy(A_							) for x in image_inputs]

       return image_inputs






@require_torch
@require_vision
class    lowerCamelCase__						(		_a			,   unittest.TestCase    ):
      a :     Union[str, Any]											=		ChineseCLIPImageProcessor if is_vision_available() else None
      def SCREAMING_SNAKE_CASE_	(		self	:	Tuple							):






       '''simple docstring'''


       __lowercase									=	ChineseCLIPImageProcessingTester(self      ,       do_center_crop=A_							)
      @property
      def SCREAMING_SNAKE_CASE_	(		self	:	Union[str, Any]							):






       '''simple docstring'''


       return self.image_processor_tester.prepare_image_processor_dict()
      def SCREAMING_SNAKE_CASE_	(		self	:	List[Any]							):






       '''simple docstring'''


       __lowercase									=	self.image_processing_class(**self.image_processor_dict							)
       self.assertTrue(hasattr(A_      ,       """do_resize"""							)							)
       self.assertTrue(hasattr(A_      ,       """size"""							)							)
       self.assertTrue(hasattr(A_      ,       """do_center_crop"""							)							)
       self.assertTrue(hasattr(A_      ,       """center_crop"""							)							)
       self.assertTrue(hasattr(A_      ,       """do_normalize"""							)							)
       self.assertTrue(hasattr(A_      ,       """image_mean"""							)							)
       self.assertTrue(hasattr(A_      ,       """image_std"""							)							)
       self.assertTrue(hasattr(A_      ,       """do_convert_rgb"""							)							)
      def SCREAMING_SNAKE_CASE_	(		self	:	List[Any]							):






       '''simple docstring'''


       __lowercase									=	self.image_processing_class.from_dict(self.image_processor_dict							)
       self.assertEqual(image_processor.size      ,       {"""height""": 2_2_4, """width""": 2_2_4}							)
       self.assertEqual(image_processor.crop_size      ,       {"""height""": 1_8, """width""": 1_8}							)

       __lowercase									=	self.image_processing_class.from_dict(self.image_processor_dict      ,       size=4_2      ,       crop_size=8_4							)
       self.assertEqual(image_processor.size      ,       {"""shortest_edge""": 4_2}							)
       self.assertEqual(image_processor.crop_size      ,       {"""height""": 8_4, """width""": 8_4}							)
      def SCREAMING_SNAKE_CASE_	(		self	:	Optional[Any]							):






       '''simple docstring'''


       pass
      def SCREAMING_SNAKE_CASE_	(		self	:	Optional[int]							):






       '''simple docstring'''


       __lowercase									=	self.image_processing_class(**self.image_processor_dict							)
       # create random PIL images
       __lowercase									=	self.image_processor_tester.prepare_inputs(equal_resolution=A_							)
       for image in image_inputs:
        self.assertIsInstance(A_      ,       Image.Image							)

       # Test not batched input
       __lowercase									=	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.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )

       # Test batched
       __lowercase									=	image_processing(A_      ,       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.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )
      def SCREAMING_SNAKE_CASE_	(		self	:	Any							):






       '''simple docstring'''


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

       # Test not batched input
       __lowercase									=	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.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )

       # Test batched
       __lowercase									=	image_processing(A_      ,       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.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )






      def SCREAMING_SNAKE_CASE_	(		self	:	Dict							):






       '''simple docstring'''


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

       # Test not batched input
       __lowercase									=	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.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )

       # Test batched
       __lowercase									=	image_processing(A_      ,       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.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )






@require_torch
@require_vision
class    lowerCamelCase__						(		_a			,   unittest.TestCase    ):
      a :     Optional[Any]											=		ChineseCLIPImageProcessor if is_vision_available() else None
      def SCREAMING_SNAKE_CASE_	(		self	:	Optional[Any]							):






       '''simple docstring'''


       __lowercase									=	ChineseCLIPImageProcessingTester(self      ,       num_channels=4      ,       do_center_crop=A_							)
       __lowercase									=	3
      @property
      def SCREAMING_SNAKE_CASE_	(		self	:	str							):






       '''simple docstring'''


       return self.image_processor_tester.prepare_image_processor_dict()
      def SCREAMING_SNAKE_CASE_	(		self	:	Optional[int]							):






       '''simple docstring'''


       __lowercase									=	self.image_processing_class(**self.image_processor_dict							)
       self.assertTrue(hasattr(A_      ,       """do_resize"""							)							)
       self.assertTrue(hasattr(A_      ,       """size"""							)							)
       self.assertTrue(hasattr(A_      ,       """do_center_crop"""							)							)
       self.assertTrue(hasattr(A_      ,       """center_crop"""							)							)
       self.assertTrue(hasattr(A_      ,       """do_normalize"""							)							)
       self.assertTrue(hasattr(A_      ,       """image_mean"""							)							)
       self.assertTrue(hasattr(A_      ,       """image_std"""							)							)
       self.assertTrue(hasattr(A_      ,       """do_convert_rgb"""							)							)
      def SCREAMING_SNAKE_CASE_	(		self	:	Union[str, Any]							):






       '''simple docstring'''


       pass






      def SCREAMING_SNAKE_CASE_	(		self	:	str							):






       '''simple docstring'''


       __lowercase									=	self.image_processing_class(**self.image_processor_dict							)
       # create random PIL images
       __lowercase									=	self.image_processor_tester.prepare_inputs(equal_resolution=A_							)
       for image in image_inputs:
        self.assertIsInstance(A_      ,       Image.Image							)

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

       # Test batched
       __lowercase									=	image_processing(A_      ,       return_tensors="""pt"""							).pixel_values
       self.assertEqual(
           encoded_images.shape      ,       (
               self.image_processor_tester.batch_size,
               self.expected_encoded_image_num_channels,
               self.image_processor_tester.crop_size["""height"""],
               self.image_processor_tester.crop_size["""width"""],
           )      ,       )
