




'''simple docstring'''
from typing import Optional, Tuple, Union

import tensorflow as tf

from ...activations_tf import ACTaFN
from ...modeling_tf_outputs import (
    TFBaseModelOutputWithNoAttention,
    TFBaseModelOutputWithPoolingAndNoAttention,
    TFImageClassifierOutputWithNoAttention,
)
from ...modeling_tf_utils import TFPreTrainedModel, TFSequenceClassificationLoss, keras_serializable, unpack_inputs
from ...tf_utils import shape_list
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_resnet import ResNetConfig


A							:      int 	=       logging.get_logger(__name__)

# General docstring
A							:      List[Any] 	=       """ResNetConfig"""

# Base docstring
A							:      Optional[Any] 	=       """microsoft/resnet-50"""
A							:      int 	=       [1, 2_048, 7, 7]

# Image classification docstring
A							:      List[Any] 	=       """microsoft/resnet-50"""
A							:      Dict 	=       """tiger cat"""

A							:      List[Any] 	=       [
    """microsoft/resnet-50""",
    # See all resnet models at https://huggingface.co/models?filter=resnet
]






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		lowerCamelCase__ = 3					,		lowerCamelCase__ = 1					,		lowerCamelCase__ = "relu"					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           __lowercase							=						kernel_size // 2
           __lowercase							=						tf.keras.layers.ConvaD(
               lowerCamelCase__					,		kernel_size=lowerCamelCase__					,		strides=lowerCamelCase__					,		padding="""valid"""					,		use_bias=lowerCamelCase__					,		name="""convolution"""     )
           # Use same default momentum and epsilon as PyTorch equivalent
           __lowercase							=						tf.keras.layers.BatchNormalization(epsilon=1E-5					,		momentum=0.9					,		name="""normalization"""     )
           __lowercase							=						ACTaFN[activation] if activation is not None else tf.keras.layers.Activation("""linear"""     )

       def     snake_case__			(    self					,		lowerCamelCase__     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase							=						__lowercase							=						(self.pad_value, self.pad_value)
           __lowercase							=						tf.pad(lowerCamelCase__					,		[(0, 0), height_pad, width_pad, (0, 0)]     )
           __lowercase							=						self.conv(lowerCamelCase__     )
           return hidden_state




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase							=						self.convolution(lowerCamelCase__     )
           __lowercase							=						self.normalization(lowerCamelCase__					,		training=lowerCamelCase__     )
           __lowercase							=						self.activation(lowerCamelCase__     )
           return hidden_state






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           __lowercase							=						TFResNetConvLayer(
               config.embedding_size					,		kernel_size=7					,		stride=2					,		activation=config.hidden_act					,		name="""embedder"""					,		)
           __lowercase							=						tf.keras.layers.MaxPoolaD(pool_size=3					,		strides=2					,		padding="""valid"""					,		name="""pooler"""     )
           __lowercase							=						config.num_channels




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase				,__lowercase				,__lowercase				,__lowercase							=						shape_list(lowerCamelCase__     )
           if tf.executing_eagerly() and num_channels != self.num_channels:
               raise ValueError(
                   """Make sure that the channel dimension of the pixel values match with the one set in the configuration."""     )
           __lowercase							=						pixel_values
           __lowercase							=						self.embedder(lowerCamelCase__     )
           __lowercase							=						tf.pad(lowerCamelCase__					,		[[0, 0], [1, 1], [1, 1], [0, 0]]     )
           __lowercase							=						self.pooler(lowerCamelCase__     )
           return hidden_state






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		lowerCamelCase__ = 2					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           __lowercase							=						tf.keras.layers.ConvaD(
               lowerCamelCase__					,		kernel_size=1					,		strides=lowerCamelCase__					,		use_bias=lowerCamelCase__					,		name="""convolution"""     )
           # Use same default momentum and epsilon as PyTorch equivalent
           __lowercase							=						tf.keras.layers.BatchNormalization(epsilon=1E-5					,		momentum=0.9					,		name="""normalization"""     )




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase							=						x
           __lowercase							=						self.convolution(lowerCamelCase__     )
           __lowercase							=						self.normalization(lowerCamelCase__					,		training=lowerCamelCase__     )
           return hidden_state






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		lowerCamelCase__					,		lowerCamelCase__ = 1					,		lowerCamelCase__ = "relu"					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           __lowercase							=						in_channels != out_channels or stride != 1
           __lowercase							=						TFResNetConvLayer(lowerCamelCase__					,		stride=lowerCamelCase__					,		name="""layer.0"""     )
           __lowercase							=						TFResNetConvLayer(lowerCamelCase__					,		activation=lowerCamelCase__					,		name="""layer.1"""     )
           __lowercase							=						(
               TFResNetShortCut(lowerCamelCase__					,		stride=lowerCamelCase__					,		name="""shortcut"""     )
               if should_apply_shortcut
               else tf.keras.layers.Activation("""linear"""					,		name="""shortcut"""     )
           )
           __lowercase							=						ACTaFN[activation]




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase							=						hidden_state
           __lowercase							=						self.conva(lowerCamelCase__					,		training=lowerCamelCase__     )
           __lowercase							=						self.conva(lowerCamelCase__					,		training=lowerCamelCase__     )
           __lowercase							=						self.shortcut(lowerCamelCase__					,		training=lowerCamelCase__     )
           hidden_state += residual
           __lowercase							=						self.activation(lowerCamelCase__     )
           return hidden_state






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		lowerCamelCase__					,		lowerCamelCase__ = 1					,		lowerCamelCase__ = "relu"					,		lowerCamelCase__ = 4					,		**lowerCamelCase__					,		)    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           __lowercase							=						in_channels != out_channels or stride != 1
           __lowercase							=						out_channels // reduction
           __lowercase							=						TFResNetConvLayer(lowerCamelCase__					,		kernel_size=1					,		name="""layer.0"""     )
           __lowercase							=						TFResNetConvLayer(lowerCamelCase__					,		stride=lowerCamelCase__					,		name="""layer.1"""     )
           __lowercase							=						TFResNetConvLayer(lowerCamelCase__					,		kernel_size=1					,		activation=lowerCamelCase__					,		name="""layer.2"""     )
           __lowercase							=						(
               TFResNetShortCut(lowerCamelCase__					,		stride=lowerCamelCase__					,		name="""shortcut"""     )
               if should_apply_shortcut
               else tf.keras.layers.Activation("""linear"""					,		name="""shortcut"""     )
           )
           __lowercase							=						ACTaFN[activation]




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase							=						hidden_state
           __lowercase							=						self.conva(lowerCamelCase__					,		training=lowerCamelCase__     )
           __lowercase							=						self.conva(lowerCamelCase__					,		training=lowerCamelCase__     )
           __lowercase							=						self.conva(lowerCamelCase__					,		training=lowerCamelCase__     )
           __lowercase							=						self.shortcut(lowerCamelCase__					,		training=lowerCamelCase__     )
           hidden_state += residual
           __lowercase							=						self.activation(lowerCamelCase__     )
           return hidden_state






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		lowerCamelCase__					,		lowerCamelCase__					,		lowerCamelCase__ = 2					,		lowerCamelCase__ = 2					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )

           __lowercase							=						TFResNetBottleNeckLayer if config.layer_type == """bottleneck""" else TFResNetBasicLayer

           __lowercase							=						[layer(lowerCamelCase__					,		lowerCamelCase__					,		stride=lowerCamelCase__					,		activation=config.hidden_act					,		name="""layers.0"""     )]
           layers += [
               layer(lowerCamelCase__					,		lowerCamelCase__					,		activation=config.hidden_act					,		name=F'layers.{i + 1}'     )
               for i in range(depth - 1     )
           ]
           __lowercase							=						layers




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False     )    ->					tf.Tensor:

           """simple docstring"""



           for layer in self.stage_layers:
               __lowercase							=						layer(lowerCamelCase__					,		training=lowerCamelCase__     )
           return hidden_state






class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):

       def __init__(    self					,		lowerCamelCase__					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           # based on `downsample_in_first_stage` the first layer of the first stage may or may not downsample the input
           __lowercase							=						[
               TFResNetStage(
                   lowerCamelCase__					,		config.embedding_size					,		config.hidden_sizes[0]					,		stride=2 if config.downsample_in_first_stage else 1					,		depth=config.depths[0]					,		name="""stages.0"""					,		)
           ]
           for i, (in_channels, out_channels, depth) in enumerate(
               zip(config.hidden_sizes					,		config.hidden_sizes[1:]					,		config.depths[1:]     )     ):
               self.stages.append(TFResNetStage(lowerCamelCase__					,		lowerCamelCase__					,		lowerCamelCase__					,		depth=lowerCamelCase__					,		name=F'stages.{i + 1}'     )     )




       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = False					,		lowerCamelCase__ = True					,		lowerCamelCase__ = False					,		)    ->					TFBaseModelOutputWithNoAttention:

           """simple docstring"""



           __lowercase							=						() if output_hidden_states else None

           for stage_module in self.stages:
               if output_hidden_states:
                   __lowercase							=						hidden_states + (hidden_state,)

               __lowercase							=						stage_module(lowerCamelCase__					,		training=lowerCamelCase__     )

           if output_hidden_states:
               __lowercase							=						hidden_states + (hidden_state,)

           if not return_dict:
               return tuple(v for v in [hidden_state, hidden_states] if v is not None     )

           return TFBaseModelOutputWithNoAttention(last_hidden_state=lowerCamelCase__					,		hidden_states=lowerCamelCase__     )






class        SCREAMING_SNAKE_CASE(				__A     ):
       snake_case_ :     Dict    =					ResNetConfig
       snake_case_ :     str    =					"""resnet"""
       snake_case_ :     List[str]    =					"""pixel_values"""

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

           """simple docstring"""



           return {"pixel_values": tf.TensorSpec(shape=(None, self.config.num_channels, 224, 224)					,		dtype=tf.floataa     )}

A							:      Optional[Any] 	=       r"""
    This model is a TensorFlow
    [tf.keras.layers.Layer](https://www.tensorflow.org/api_docs/python/tf/keras/layers/Layer) sub-class. Use it as a
    regular TensorFlow Module and refer to the TensorFlow documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`ResNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~TFPreTrainedModel.from_pretrained`] method to load the model weights.
"""


A							:      Union[str, Any] 	=       r"""
    Args:
        pixel_values (`tf.Tensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`ConvNextImageProcessor.__call__`] for details.

        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
"""






@keras_serializable
class        SCREAMING_SNAKE_CASE(				tf.keras.layers.Layer     ):
       snake_case_ :     List[str]    =					ResNetConfig

       def __init__(    self					,		lowerCamelCase__					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(**lowerCamelCase__     )
           __lowercase							=						config
           __lowercase							=						TFResNetEmbeddings(lowerCamelCase__					,		name="""embedder"""     )
           __lowercase							=						TFResNetEncoder(lowerCamelCase__					,		name="""encoder"""     )
           __lowercase							=						tf.keras.layers.GlobalAveragePoolingaD(keepdims=lowerCamelCase__     )




       @unpack_inputs
       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = None					,		lowerCamelCase__ = None					,		lowerCamelCase__ = False					,		)    ->					Union[Tuple[tf.Tensor], TFBaseModelOutputWithPoolingAndNoAttention]:

           """simple docstring"""



           __lowercase							=						(
               output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
           )
           __lowercase							=						return_dict if return_dict is not None else self.config.use_return_dict

           # TF 2.0 image layers can't use NCHW format when running on CPU.
           # We transpose to NHWC format and then transpose back after the full forward pass.
           # (batch_size, num_channels, height, width) -> (batch_size, height, width, num_channels)
           __lowercase							=						tf.transpose(lowerCamelCase__					,		perm=[0, 2, 3, 1]     )
           __lowercase							=						self.embedder(lowerCamelCase__					,		training=lowerCamelCase__     )

           __lowercase							=						self.encoder(
               lowerCamelCase__					,		output_hidden_states=lowerCamelCase__					,		return_dict=lowerCamelCase__					,		training=lowerCamelCase__     )

           __lowercase							=						encoder_outputs[0]

           __lowercase							=						self.pooler(lowerCamelCase__     )

           # Transpose all the outputs to the NCHW format
           # (batch_size, height, width, num_channels) -> (batch_size, num_channels, height, width)
           __lowercase							=						tf.transpose(lowerCamelCase__					,		(0, 3, 1, 2)     )
           __lowercase							=						tf.transpose(lowerCamelCase__					,		(0, 3, 1, 2)     )
           __lowercase							=						()
           for hidden_state in encoder_outputs[1:]:
               __lowercase							=						hidden_states + tuple(tf.transpose(lowerCamelCase__					,		(0, 3, 1, 2)     ) for h in hidden_state     )

           if not return_dict:
               return (last_hidden_state, pooled_output) + hidden_states

           __lowercase							=						hidden_states if output_hidden_states else None

           return TFBaseModelOutputWithPoolingAndNoAttention(
               last_hidden_state=lowerCamelCase__					,		pooler_output=lowerCamelCase__					,		hidden_states=lowerCamelCase__					,		)






@add_start_docstrings(
    """The bare ResNet model outputting raw features without any specific head on top."""   ,      __A   ,      )
class        SCREAMING_SNAKE_CASE(				__A     ):

       def __init__(    self					,		lowerCamelCase__					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(lowerCamelCase__					,		**lowerCamelCase__     )
           __lowercase							=						TFResNetMainLayer(config=lowerCamelCase__					,		name="""resnet"""     )




       @add_start_docstrings_to_model_forward(lowerCamelCase__     )
       @add_code_sample_docstrings(
           checkpoint=_CHECKPOINT_FOR_DOC					,		output_type=lowerCamelCase__					,		config_class=_CONFIG_FOR_DOC					,		modality="""vision"""					,		expected_output=_EXPECTED_OUTPUT_SHAPE					,		)
       @unpack_inputs
       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__ = None					,		lowerCamelCase__ = None					,		lowerCamelCase__ = False					,		)    ->					Union[Tuple[tf.Tensor], TFBaseModelOutputWithPoolingAndNoAttention]:

           """simple docstring"""



           __lowercase							=						(
               output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
           )
           __lowercase							=						return_dict if return_dict is not None else self.config.use_return_dict

           __lowercase							=						self.resnet(
               pixel_values=lowerCamelCase__					,		output_hidden_states=lowerCamelCase__					,		return_dict=lowerCamelCase__					,		training=lowerCamelCase__					,		)
           return resnet_outputs






@add_start_docstrings(
    """
    ResNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    """   ,      __A   ,      )
class        SCREAMING_SNAKE_CASE(				__A   ,      __A     ):

       def __init__(    self					,		lowerCamelCase__					,		**lowerCamelCase__     )    ->					None:

           """simple docstring"""



           super().__init__(lowerCamelCase__					,		**lowerCamelCase__     )
           __lowercase							=						config.num_labels
           __lowercase							=						TFResNetMainLayer(lowerCamelCase__					,		name="""resnet"""     )
           # classification head
           __lowercase							=						(
               tf.keras.layers.Dense(config.num_labels					,		name="""classifier.1"""     )
               if config.num_labels > 0
               else tf.keras.layers.Activation("""linear"""					,		name="""classifier.1"""     )
           )

       def     snake_case__			(    self					,		lowerCamelCase__     )    ->					tf.Tensor:

           """simple docstring"""



           __lowercase							=						tf.keras.layers.Flatten()(lowerCamelCase__     )
           __lowercase							=						self.classifier_layer(lowerCamelCase__     )
           return logits




       @add_start_docstrings_to_model_forward(lowerCamelCase__     )
       @add_code_sample_docstrings(
           checkpoint=_IMAGE_CLASS_CHECKPOINT					,		output_type=lowerCamelCase__					,		config_class=_CONFIG_FOR_DOC					,		expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT					,		)
       @unpack_inputs
       def     snake_case__			(    self					,		lowerCamelCase__ = None					,		lowerCamelCase__ = None					,		lowerCamelCase__ = None					,		lowerCamelCase__ = None					,		lowerCamelCase__ = False					,		)    ->					Union[Tuple[tf.Tensor], TFImageClassifierOutputWithNoAttention]:

           """simple docstring"""



           __lowercase							=						return_dict if return_dict is not None else self.config.use_return_dict

           __lowercase							=						self.resnet(
               lowerCamelCase__					,		output_hidden_states=lowerCamelCase__					,		return_dict=lowerCamelCase__					,		training=lowerCamelCase__     )

           __lowercase							=						outputs.pooler_output if return_dict else outputs[1]

           __lowercase							=						self.classifier(lowerCamelCase__     )

           __lowercase							=						None if labels is None else self.hf_compute_loss(lowerCamelCase__					,		lowerCamelCase__     )

           if not return_dict:
               __lowercase							=						(logits,) + outputs[2:]
               return (loss,) + output if loss is not None else output

           return TFImageClassifierOutputWithNoAttention(loss=lowerCamelCase__					,		logits=lowerCamelCase__					,		hidden_states=outputs.hidden_states     )










'''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 BlipImageProcessor






class        SCREAMING_SNAKE_CASE(				unittest.TestCase     ):

       def __init__(    self					,		lowerCamelCase__					,		lowerCamelCase__=7					,		lowerCamelCase__=3					,		lowerCamelCase__=18					,		lowerCamelCase__=30					,		lowerCamelCase__=400					,		lowerCamelCase__=True					,		lowerCamelCase__=None					,		lowerCamelCase__=True					,		lowerCamelCase__=False					,		lowerCamelCase__=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]					,		lowerCamelCase__=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]					,		lowerCamelCase__=True					,		)    ->					Union[str, Any]:

           """simple docstring"""



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

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

           """simple docstring"""



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




       def     snake_case__			(    self					,		lowerCamelCase__=False					,		lowerCamelCase__=False					,		lowerCamelCase__=False     )    ->					Tuple:

           """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(
                           255					,		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(255					,		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(lowerCamelCase__					,		0					,		-1     )     ) for x in image_inputs]

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

           return image_inputs






@require_torch
@require_vision
class        SCREAMING_SNAKE_CASE(				__A   ,      unittest.TestCase     ):
       snake_case_ :     Optional[int]    =					BlipImageProcessor if is_vision_available() else None

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

           """simple docstring"""



           __lowercase							=						BlipImageProcessingTester(self     )

       @property
       def     snake_case__			(    self     )    ->					Optional[int]:

           """simple docstring"""



           return self.image_processor_tester.prepare_image_processor_dict()

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

           """simple docstring"""



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

       def     snake_case__			(    self     )    ->					Any:

           """simple docstring"""



           pass

       def     snake_case__			(    self     )    ->					List[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=lowerCamelCase__     )
           for image in image_inputs:
               self.assertIsInstance(lowerCamelCase__					,		Image.Image     )

           # Test not batched input
           __lowercase							=						image_processor(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
           __lowercase							=						image_processor(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     snake_case__			(    self     )    ->					int:

           """simple docstring"""



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

           # Test not batched input
           __lowercase							=						image_processor(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
           __lowercase							=						image_processor(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     snake_case__			(    self     )    ->					Any:

           """simple docstring"""



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

           # Test not batched input
           __lowercase							=						image_processor(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
           __lowercase							=						image_processor(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"""],
               )					,		)






@require_torch
@require_vision
class        SCREAMING_SNAKE_CASE(				__A   ,      unittest.TestCase     ):
       snake_case_ :     Union[str, Any]    =					BlipImageProcessor if is_vision_available() else None

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

           """simple docstring"""



           __lowercase							=						BlipImageProcessingTester(self					,		num_channels=4     )
           __lowercase							=						3

       @property
       def     snake_case__			(    self     )    ->					str:

           """simple docstring"""



           return self.image_processor_tester.prepare_image_processor_dict()

       def     snake_case__			(    self     )    ->					Any:

           """simple docstring"""



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

       def     snake_case__			(    self     )    ->					Any:

           """simple docstring"""



           pass




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

           """simple docstring"""



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

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

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




