

'''simple docstring'''





from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


UpperCamelCase_    						=       logging.get_logger(__name__)

# General docstring
UpperCamelCase_    						=       """RegNetConfig"""

# Base docstring
UpperCamelCase_    						=       """facebook/regnet-y-040"""
UpperCamelCase_    						=       [1, 1088, 7, 7]

# Image classification docstring
UpperCamelCase_    						=       """facebook/regnet-y-040"""
UpperCamelCase_    						=       """tabby, tabby cat"""

UpperCamelCase_    						=       [
    """facebook/regnet-y-040""",
    # See all regnet models at https://huggingface.co/models?filter=regnet
]





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		Dict		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int = 3		,					UpperCAmelCase__     :		int = 1		,					UpperCAmelCase__     :		int = 1		,					UpperCAmelCase__     :		Optional[str] = "relu"		,					):
										'''simple docstring'''
										super().__init__()
										lowercase :							Tuple    		=nn.Convad(
										    UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=UpperCAmelCase__		,					stride=UpperCAmelCase__		,					padding=kernel_size // 2		,					groups=UpperCAmelCase__		,					bias=UpperCAmelCase__		,					)
										lowercase :							Optional[int]    		=nn.BatchNormad(UpperCAmelCase__   )
										lowercase :							Any    		=ACTaFN[activation] if activation is not None else nn.Identity()







				def  lowerCamelCase_	(       self     :		Optional[int]		,					UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=self.convolution(UpperCAmelCase__   )
										lowercase :							int    		=self.normalization(UpperCAmelCase__   )
										lowercase :							Tuple    		=self.activation(UpperCAmelCase__   )
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		str		,					UpperCAmelCase__     :		RegNetConfig   ):
										'''simple docstring'''
										super().__init__()
										lowercase :							Tuple    		=RegNetConvLayer(
										    config.num_channels		,					config.embedding_size		,					kernel_size=3		,					stride=2		,					activation=config.hidden_act   )
										lowercase :							Optional[int]    		=config.num_channels







				def  lowerCamelCase_	(       self     :		Union[str, Any]		,					UpperCAmelCase__     :		List[str]   ):
										'''simple docstring'''
										lowercase :							Optional[Any]    		=pixel_values.shape[1]
										if 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 :							List[Any]    		=self.embedder(UpperCAmelCase__   )
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		List[Any]		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int = 2   ):
										'''simple docstring'''
										super().__init__()
										lowercase :							Tuple    		=nn.Convad(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1		,					stride=UpperCAmelCase__		,					bias=UpperCAmelCase__   )
										lowercase :							List[Any]    		=nn.BatchNormad(UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		Tuple		,					UpperCAmelCase__     :		Tensor   ):
										'''simple docstring'''
										lowercase :							List[str]    		=self.convolution(UpperCAmelCase__   )
										lowercase :							Any    		=self.normalization(UpperCAmelCase__   )
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		Union[str, Any]		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int   ):
										'''simple docstring'''
										super().__init__()

										lowercase :							Union[str, Any]    		=nn.AdaptiveAvgPoolad((1, 1)   )
										lowercase :							Dict    		=nn.Sequential(
										    nn.Convad(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1   )		,					nn.ReLU()		,					nn.Convad(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1   )		,					nn.Sigmoid()		,					)







				def  lowerCamelCase_	(       self     :		Optional[int]		,					UpperCAmelCase__     :		List[Any]   ):
										'''simple docstring'''
										# b c h w -> b c 1 1
										lowercase :							int    		=self.pooler(UpperCAmelCase__   )
										lowercase :							List[str]    		=self.attention(UpperCAmelCase__   )
										lowercase :							List[str]    		=hidden_state * attention
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		str		,					UpperCAmelCase__     :		RegNetConfig		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int = 1   ):
										'''simple docstring'''
										super().__init__()
										lowercase :							Any    		=in_channels != out_channels or stride != 1
										lowercase :							int    		=max(1		,					out_channels // config.groups_width   )
										lowercase :							Optional[int]    		=(
										    RegNetShortCut(UpperCAmelCase__		,					UpperCAmelCase__		,					stride=UpperCAmelCase__   ) if should_apply_shortcut else nn.Identity()
										)
										lowercase :							Tuple    		=nn.Sequential(
										    RegNetConvLayer(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1		,					activation=config.hidden_act   )		,					RegNetConvLayer(UpperCAmelCase__		,					UpperCAmelCase__		,					stride=UpperCAmelCase__		,					groups=UpperCAmelCase__		,					activation=config.hidden_act   )		,					RegNetConvLayer(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1		,					activation=UpperCAmelCase__   )		,					)
										lowercase :							str    		=ACTaFN[config.hidden_act]







				def  lowerCamelCase_	(       self     :		List[Any]		,					UpperCAmelCase__     :		Optional[Any]   ):
										'''simple docstring'''
										lowercase :							str    		=hidden_state
										lowercase :							int    		=self.layer(UpperCAmelCase__   )
										lowercase :							Any    		=self.shortcut(UpperCAmelCase__   )
										hidden_state += residual
										lowercase :							Union[str, Any]    		=self.activation(UpperCAmelCase__   )
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		List[Any]		,					UpperCAmelCase__     :		RegNetConfig		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int = 1   ):
										'''simple docstring'''
										super().__init__()
										lowercase :							str    		=in_channels != out_channels or stride != 1
										lowercase :							Optional[int]    		=max(1		,					out_channels // config.groups_width   )
										lowercase :							str    		=(
										    RegNetShortCut(UpperCAmelCase__		,					UpperCAmelCase__		,					stride=UpperCAmelCase__   ) if should_apply_shortcut else nn.Identity()
										)
										lowercase :							Union[str, Any]    		=nn.Sequential(
										    RegNetConvLayer(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1		,					activation=config.hidden_act   )		,					RegNetConvLayer(UpperCAmelCase__		,					UpperCAmelCase__		,					stride=UpperCAmelCase__		,					groups=UpperCAmelCase__		,					activation=config.hidden_act   )		,					RegNetSELayer(UpperCAmelCase__		,					reduced_channels=int(round(in_channels / 4   )   )   )		,					RegNetConvLayer(UpperCAmelCase__		,					UpperCAmelCase__		,					kernel_size=1		,					activation=UpperCAmelCase__   )		,					)
										lowercase :							Union[str, Any]    		=ACTaFN[config.hidden_act]







				def  lowerCamelCase_	(       self     :		Any		,					UpperCAmelCase__     :		Tuple   ):
										'''simple docstring'''
										lowercase :							Dict    		=hidden_state
										lowercase :							Any    		=self.layer(UpperCAmelCase__   )
										lowercase :							Dict    		=self.shortcut(UpperCAmelCase__   )
										hidden_state += residual
										lowercase :							str    		=self.activation(UpperCAmelCase__   )
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		Dict		,					UpperCAmelCase__     :		RegNetConfig		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int = 2		,					UpperCAmelCase__     :		int = 2		,					):
										'''simple docstring'''
										super().__init__()

										lowercase :							Union[str, Any]    		=RegNetXLayer if config.layer_type == '''x''' else RegNetYLayer

										lowercase :							List[Any]    		=nn.Sequential(
										    # downsampling is done in the first layer with stride of 2
										    layer(
										        UpperCAmelCase__		,					UpperCAmelCase__		,					UpperCAmelCase__		,					stride=UpperCAmelCase__		,					)		,					*[layer(UpperCAmelCase__		,					UpperCAmelCase__		,					UpperCAmelCase__   ) for _ in range(depth - 1   )]		,					)







				def  lowerCamelCase_	(       self     :		List[Any]		,					UpperCAmelCase__     :		Union[str, Any]   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=self.layers(UpperCAmelCase__   )
										return hidden_state





class 		__SCREAMING_SNAKE_CASE							(			nn.Module      ):







				def __init__(       self     :		int		,					UpperCAmelCase__     :		RegNetConfig   ):
										'''simple docstring'''
										super().__init__()
										lowercase :							str    		=nn.ModuleList([]   )
										# based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
										self.stages.append(
										    RegNetStage(
										        UpperCAmelCase__		,					config.embedding_size		,					config.hidden_sizes[0]		,					stride=2 if config.downsample_in_first_stage else 1		,					depth=config.depths[0]		,					)   )
										lowercase :							List[str]    		=zip(config.hidden_sizes		,					config.hidden_sizes[1:]   )
										for (in_channels, out_channels), depth in zip(UpperCAmelCase__		,					config.depths[1:]   ):
																self.stages.append(RegNetStage(UpperCAmelCase__		,					UpperCAmelCase__		,					UpperCAmelCase__		,					depth=UpperCAmelCase__   )   )







				def  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		Tensor		,					UpperCAmelCase__     :		bool = False		,					UpperCAmelCase__     :		bool = True   ):
										'''simple docstring'''
										lowercase :							List[str]    		=() if output_hidden_states else None

										for stage_module in self.stages:
																if output_hidden_states:
																						lowercase :							List[Any]    		=hidden_states + (hidden_state,)

																lowercase :							int    		=stage_module(UpperCAmelCase__   )

										if output_hidden_states:
																lowercase :							Tuple    		=hidden_states + (hidden_state,)

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

										return BaseModelOutputWithNoAttention(last_hidden_state=UpperCAmelCase__		,					hidden_states=UpperCAmelCase__   )





class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):
				lowerCamelCase_		       =    RegNetConfig
				lowerCamelCase_		       =    'regnet'
				lowerCamelCase_		       =    'pixel_values'
				lowerCamelCase_		       =    True







				def  lowerCamelCase_	(       self     :		Union[str, Any]		,					UpperCAmelCase__     :		Tuple   ):
										'''simple docstring'''
										if isinstance(UpperCAmelCase__		,					nn.Convad   ):
																nn.init.kaiming_normal_(module.weight		,					mode='''fan_out'''		,					nonlinearity='''relu'''   )
										elif isinstance(UpperCAmelCase__		,					(nn.BatchNormad, nn.GroupNorm)   ):
																nn.init.constant_(module.weight		,					1   )
																nn.init.constant_(module.bias		,					0   )







				def  lowerCamelCase_	(       self     :		Optional[int]		,					UpperCAmelCase__     :		Any		,					UpperCAmelCase__     :		Optional[int]=False   ):
										'''simple docstring'''
										if isinstance(UpperCAmelCase__		,					UpperCAmelCase__   ):
																lowercase :							int    		=value



UpperCamelCase_    						=       r"""
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it
    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`RegNetConfig`]): 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 [`~PreTrainedModel.from_pretrained`] method to load the model weights.
"""

UpperCamelCase_    						=       r"""
    Args:
        pixel_values (`torch.FloatTensor` 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 [`~file_utils.ModelOutput`] instead of a plain tuple.
"""





@add_start_docstrings(
    'The bare RegNet model outputting raw features without any specific head on top.'						,							lowercase__						,							)
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):







				def __init__(       self     :		Any		,					UpperCAmelCase__     :		List[Any]   ):
										'''simple docstring'''
										super().__init__(UpperCAmelCase__   )
										lowercase :							str    		=config
										lowercase :							Any    		=RegNetEmbeddings(UpperCAmelCase__   )
										lowercase :							Union[str, Any]    		=RegNetEncoder(UpperCAmelCase__   )
										lowercase :							Any    		=nn.AdaptiveAvgPoolad((1, 1)   )
										# Initialize weights and apply final processing
										self.post_init()







				@add_start_docstrings_to_model_forward(UpperCAmelCase__   )
				@add_code_sample_docstrings(
				    checkpoint=_CHECKPOINT_FOR_DOC		,					output_type=UpperCAmelCase__		,					config_class=_CONFIG_FOR_DOC		,					modality='''vision'''		,					expected_output=_EXPECTED_OUTPUT_SHAPE		,					)
				def  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		Tensor		,					UpperCAmelCase__     :		Optional[bool] = None		,					UpperCAmelCase__     :		Optional[bool] = None   ):
										'''simple docstring'''
										lowercase :							str    		=(
										    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
										)
										lowercase :							Dict    		=return_dict if return_dict is not None else self.config.use_return_dict

										lowercase :							Tuple    		=self.embedder(UpperCAmelCase__   )

										lowercase :							Optional[Any]    		=self.encoder(
										    UpperCAmelCase__		,					output_hidden_states=UpperCAmelCase__		,					return_dict=UpperCAmelCase__   )

										lowercase :							Optional[int]    		=encoder_outputs[0]

										lowercase :							Optional[int]    		=self.pooler(UpperCAmelCase__   )

										if not return_dict:
																return (last_hidden_state, pooled_output) + encoder_outputs[1:]

										return BaseModelOutputWithPoolingAndNoAttention(
										    last_hidden_state=UpperCAmelCase__		,					pooler_output=UpperCAmelCase__		,					hidden_states=encoder_outputs.hidden_states		,					)





@add_start_docstrings(
    '\n    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    '						,							lowercase__						,							)
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class 		__SCREAMING_SNAKE_CASE							(			lowercase__      ):







				def __init__(       self     :		str		,					UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										super().__init__(UpperCAmelCase__   )
										lowercase :							Dict    		=config.num_labels
										lowercase :							Union[str, Any]    		=RegNetModel(UpperCAmelCase__   )
										# classification head
										lowercase :							Optional[int]    		=nn.Sequential(
										    nn.Flatten()		,					nn.Linear(config.hidden_sizes[-1]		,					config.num_labels   ) if config.num_labels > 0 else nn.Identity()		,					)
										# initialize weights and apply final processing
										self.post_init()







				@add_start_docstrings_to_model_forward(UpperCAmelCase__   )
				@add_code_sample_docstrings(
				    checkpoint=_IMAGE_CLASS_CHECKPOINT		,					output_type=UpperCAmelCase__		,					config_class=_CONFIG_FOR_DOC		,					expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT		,					)
				def  lowerCamelCase_	(       self     :		str		,					UpperCAmelCase__     :		Optional[torch.FloatTensor] = None		,					UpperCAmelCase__     :		Optional[torch.LongTensor] = None		,					UpperCAmelCase__     :		Optional[bool] = None		,					UpperCAmelCase__     :		Optional[bool] = None		,					):
										'''simple docstring'''
										lowercase :							Dict    		=return_dict if return_dict is not None else self.config.use_return_dict

										lowercase :							Union[str, Any]    		=self.regnet(UpperCAmelCase__		,					output_hidden_states=UpperCAmelCase__		,					return_dict=UpperCAmelCase__   )

										lowercase :							int    		=outputs.pooler_output if return_dict else outputs[1]

										lowercase :							Optional[int]    		=self.classifier(UpperCAmelCase__   )

										lowercase :							Any    		=None

										if labels is not None:
																if self.config.problem_type is None:
																						if self.num_labels == 1:
																												lowercase :							Optional[int]    		='''regression'''
																						elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
																												lowercase :							List[str]    		='''single_label_classification'''
																						else:
																												lowercase :							int    		='''multi_label_classification'''
																if self.config.problem_type == "regression":
																						lowercase :							str    		=MSELoss()
																						if self.num_labels == 1:
																												lowercase :							Union[str, Any]    		=loss_fct(logits.squeeze()		,					labels.squeeze()   )
																						else:
																												lowercase :							str    		=loss_fct(UpperCAmelCase__		,					UpperCAmelCase__   )
																elif self.config.problem_type == "single_label_classification":
																						lowercase :							Tuple    		=CrossEntropyLoss()
																						lowercase :							Union[str, Any]    		=loss_fct(logits.view(-1		,					self.num_labels   )		,					labels.view(-1   )   )
																elif self.config.problem_type == "multi_label_classification":
																						lowercase :							Optional[int]    		=BCEWithLogitsLoss()
																						lowercase :							List[Any]    		=loss_fct(UpperCAmelCase__		,					UpperCAmelCase__   )

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

										return ImageClassifierOutputWithNoAttention(loss=UpperCAmelCase__		,					logits=UpperCAmelCase__		,					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, prepare_image_inputs


if is_torch_available():
     import torch

if is_vision_available():
     from PIL import Image

     from transformers import MobileViTImageProcessor





class      lowerCAmelCase (			unittest.TestCase):


       def __init__( self     ,	__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE=7     ,	__SCREAMING_SNAKE_CASE=3     ,	__SCREAMING_SNAKE_CASE=18     ,	__SCREAMING_SNAKE_CASE=30     ,	__SCREAMING_SNAKE_CASE=400     ,	__SCREAMING_SNAKE_CASE=True     ,	__SCREAMING_SNAKE_CASE=None     ,	__SCREAMING_SNAKE_CASE=True     ,	__SCREAMING_SNAKE_CASE=None     ,	__SCREAMING_SNAKE_CASE=True     ,	)   ->	Tuple:



            '''simple docstring'''




            __snake_case            =	size if size is not None else {'''shortest_edge''': 20}
            __snake_case            =	crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
            __snake_case            =	parent
            __snake_case            =	batch_size
            __snake_case            =	num_channels
            __snake_case            =	image_size
            __snake_case            =	min_resolution
            __snake_case            =	max_resolution
            __snake_case            =	do_resize
            __snake_case            =	size
            __snake_case            =	do_center_crop
            __snake_case            =	crop_size
            __snake_case            =	do_flip_channel_order




       def    lowerCAmelCase   ( self	)   ->	Union[str, 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_flip_channel_order": self.do_flip_channel_order,
            }





@require_torch
@require_vision
class      lowerCAmelCase (			__lowerCAmelCase					, unittest.TestCase):
       __lowercase	:   Union[str, Any]										=      MobileViTImageProcessor if is_vision_available() else None


       def    lowerCAmelCase   ( self	)   ->	str:



            '''simple docstring'''




            __snake_case            =	MobileViTImageProcessingTester(self	)


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



            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()


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



            '''simple docstring'''




            __snake_case            =	self.image_processing_class(**self.image_processor_dict	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_resize'''	)	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''size'''	)	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_center_crop'''	)	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''center_crop'''	)	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_flip_channel_order'''	)	)


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



            '''simple docstring'''




            __snake_case            =	self.image_processing_class.from_dict(self.image_processor_dict	)
            self.assertEqual(image_processor.size     ,	{'''shortest_edge''': 20}	)
            self.assertEqual(image_processor.crop_size     ,	{'''height''': 18, '''width''': 18}	)

            __snake_case            =	self.image_processing_class.from_dict(self.image_processor_dict     ,	size=42     ,	crop_size=84	)
            self.assertEqual(image_processor.size     ,	{'''shortest_edge''': 42}	)
            self.assertEqual(image_processor.crop_size     ,	{'''height''': 84, '''width''': 84}	)


       def    lowerCAmelCase   ( self	)   ->	Optional[Any]:



            '''simple docstring'''




            pass


       def    lowerCAmelCase   ( self	)   ->	str:



            '''simple docstring'''




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

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

            # Test batched
            __snake_case            =	image_processing(__SCREAMING_SNAKE_CASE     ,	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    lowerCAmelCase   ( self	)   ->	Tuple:



            '''simple docstring'''




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

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

            # Test batched
            __snake_case            =	image_processing(__SCREAMING_SNAKE_CASE     ,	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    lowerCAmelCase   ( self	)   ->	Tuple:



            '''simple docstring'''




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

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

            # Test batched
            __snake_case            =	image_processing(__SCREAMING_SNAKE_CASE     ,	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'''],
                )     ,	)






