





"""simple docstring"""





from typing import Optional, Tuple, Union

import tensorflow as tf

from ...activations_tf import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_tf_outputs import (
    TFBaseModelOutputWithNoAttention,
    TFBaseModelOutputWithPoolingAndNoAttention,
    TFSequenceClassifierOutput,
)
from ...modeling_tf_utils import TFPreTrainedModel, TFSequenceClassificationLoss, keras_serializable, unpack_inputs
from ...tf_utils import shape_list
from ...utils import logging
from .configuration_regnet import RegNetConfig


UpperCamelCase_					:						Optional[int]				= logging.get_logger(__name__)

# General docstring
UpperCamelCase_					:						Optional[int]				= '''RegNetConfig'''

# Base docstring
UpperCamelCase_					:						Tuple				= '''facebook/regnet-y-040'''
UpperCamelCase_					:						List[str]				= [1, 1088, 7, 7]

# Image classification docstring
UpperCamelCase_					:						List[str]				= '''facebook/regnet-y-040'''
UpperCamelCase_					:						Optional[int]				= '''tabby, tabby cat'''

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



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




			"""simple docstring"""







			def __init__(				self						:					Tuple       ,   _snake_case						:					int       ,   _snake_case						:					int = 3       ,   _snake_case						:					int = 1       ,   _snake_case						:					int = 1       ,   _snake_case						:					Optional[str] = "relu"       ,   **_snake_case						:					List[Any]       ,   )      -> List[str]:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								# The padding and conv has been verified in
								# https://colab.research.google.com/gist/sayakpaul/854bc10eeaf21c9ee2119e0b9f3841a7/scratchpad.ipynb
								A_				 =						tf.keras.layers.ZeroPaddingaD(padding=kernel_size // 2	)
								A_				 =						tf.keras.layers.ConvaD(
								    filters=_snake_case       ,   kernel_size=_snake_case       ,   strides=_snake_case       ,   padding="VALID"       ,   groups=_snake_case       ,   use_bias=_snake_case       ,   name="convolution"       ,   )
								A_				 =						tf.keras.layers.BatchNormalization(epsilon=1e-5       ,   momentum=0.9       ,   name="normalization"	)
								A_				 =						ACTaFN[activation] if activation is not None else tf.identity






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







								"""simple docstring"""
								A_				 =						self.convolution(self.padding(_snake_case	)	)
								A_				 =						self.normalization(_snake_case	)
								A_				 =						self.activation(_snake_case	)
								return hidden_state





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




			"""simple docstring"""







			def __init__(				self						:					Optional[int]       ,   _snake_case						:					RegNetConfig       ,   **_snake_case						:					List[Any]	)      -> str:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								A_				 =						config.num_channels
								A_				 =						TFRegNetConvLayer(
								    out_channels=config.embedding_size       ,   kernel_size=3       ,   stride=2       ,   activation=config.hidden_act       ,   name="embedder"       ,   )






			def      lowerCamelCase__     (				self						:					List[str]       ,   _snake_case						:					Union[str, Any]	)      -> Union[str, Any]:







								"""simple docstring"""
								A_				 =						shape_list(_snake_case	)[1]
								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."	)

								# When running on CPU, `tf.keras.layers.Conv2D` doesn't support `NCHW` format.
								# So change the input format from `NCHW` to `NHWC`.
								# shape = (batch_size, in_height, in_width, in_channels=num_channels)
								A_				 =						tf.transpose(_snake_case       ,   perm=(0, 2, 3, 1)	)
								A_				 =						self.embedder(_snake_case	)
								return hidden_state





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




			"""simple docstring"""







			def __init__(				self						:					List[str]       ,   _snake_case						:					int       ,   _snake_case						:					int = 2       ,   **_snake_case						:					Any	)      -> int:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								A_				 =						tf.keras.layers.ConvaD(
								    filters=_snake_case       ,   kernel_size=1       ,   strides=_snake_case       ,   use_bias=_snake_case       ,   name="convolution"	)
								A_				 =						tf.keras.layers.BatchNormalization(epsilon=1e-5       ,   momentum=0.9       ,   name="normalization"	)






			def      lowerCamelCase__     (				self						:					Optional[int]       ,   _snake_case						:					tf.Tensor       ,   _snake_case						:					bool = False	)      -> tf.Tensor:







								"""simple docstring"""
								return self.normalization(self.convolution(_snake_case	)       ,   training=_snake_case	)





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




			"""simple docstring"""







			def __init__(				self						:					str       ,   _snake_case						:					int       ,   _snake_case						:					int       ,   **_snake_case						:					str	)      -> Dict:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								A_				 =						tf.keras.layers.GlobalAveragePoolingaD(keepdims=_snake_case       ,   name="pooler"	)
								A_				 =						[
								    tf.keras.layers.ConvaD(filters=_snake_case       ,   kernel_size=1       ,   activation="relu"       ,   name="attention.0"	),
								    tf.keras.layers.ConvaD(filters=_snake_case       ,   kernel_size=1       ,   activation="sigmoid"       ,   name="attention.2"	),
								]






			def      lowerCamelCase__     (				self						:					int       ,   _snake_case						:					Any	)      -> str:







								"""simple docstring"""
								A_				 =						self.pooler(_snake_case	)
								for layer_module in self.attention:
													A_				 =						layer_module(_snake_case	)
								A_				 =						hidden_state * pooled
								return hidden_state





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




			"""simple docstring"""







			def __init__(				self						:					str       ,   _snake_case						:					RegNetConfig       ,   _snake_case						:					int       ,   _snake_case						:					int       ,   _snake_case						:					int = 1       ,   **_snake_case						:					Union[str, Any]	)      -> List[str]:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								A_				 =						in_channels != out_channels or stride != 1
								A_				 =						max(1       ,   out_channels // config.groups_width	)
								A_				 =						(
								    TFRegNetShortCut(_snake_case       ,   stride=_snake_case       ,   name="shortcut"	)
								    if should_apply_shortcut
								    else tf.keras.layers.Activation("linear"       ,   name="shortcut"	)
								)
								# `self.layers` instead of `self.layer` because that is a reserved argument.
								A_				 =						[
								    TFRegNetConvLayer(_snake_case       ,   kernel_size=1       ,   activation=config.hidden_act       ,   name="layer.0"	),
								    TFRegNetConvLayer(
								        _snake_case       ,   stride=_snake_case       ,   groups=_snake_case       ,   activation=config.hidden_act       ,   name="layer.1"	),
								    TFRegNetConvLayer(_snake_case       ,   kernel_size=1       ,   activation=_snake_case       ,   name="layer.2"	),
								]
								A_				 =						ACTaFN[config.hidden_act]






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







								"""simple docstring"""
								A_				 =						hidden_state
								for layer_module in self.layers:
													A_				 =						layer_module(_snake_case	)
								A_				 =						self.shortcut(_snake_case	)
								hidden_state += residual
								A_				 =						self.activation(_snake_case	)
								return hidden_state





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




			"""simple docstring"""







			def __init__(				self						:					Dict       ,   _snake_case						:					RegNetConfig       ,   _snake_case						:					int       ,   _snake_case						:					int       ,   _snake_case						:					int = 1       ,   **_snake_case						:					Tuple	)      -> Optional[Any]:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								A_				 =						in_channels != out_channels or stride != 1
								A_				 =						max(1       ,   out_channels // config.groups_width	)
								A_				 =						(
								    TFRegNetShortCut(_snake_case       ,   stride=_snake_case       ,   name="shortcut"	)
								    if should_apply_shortcut
								    else tf.keras.layers.Activation("linear"       ,   name="shortcut"	)
								)
								A_				 =						[
								    TFRegNetConvLayer(_snake_case       ,   kernel_size=1       ,   activation=config.hidden_act       ,   name="layer.0"	),
								    TFRegNetConvLayer(
								        _snake_case       ,   stride=_snake_case       ,   groups=_snake_case       ,   activation=config.hidden_act       ,   name="layer.1"	),
								    TFRegNetSELayer(_snake_case       ,   reduced_channels=int(round(in_channels / 4	)	)       ,   name="layer.2"	),
								    TFRegNetConvLayer(_snake_case       ,   kernel_size=1       ,   activation=_snake_case       ,   name="layer.3"	),
								]
								A_				 =						ACTaFN[config.hidden_act]






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







								"""simple docstring"""
								A_				 =						hidden_state
								for layer_module in self.layers:
													A_				 =						layer_module(_snake_case	)
								A_				 =						self.shortcut(_snake_case	)
								hidden_state += residual
								A_				 =						self.activation(_snake_case	)
								return hidden_state





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




			"""simple docstring"""







			def __init__(				self						:					Optional[Any]       ,   _snake_case						:					RegNetConfig       ,   _snake_case						:					int       ,   _snake_case						:					int       ,   _snake_case						:					int = 2       ,   _snake_case						:					int = 2       ,   **_snake_case						:					Optional[Any]	)      -> Optional[Any]:







								"""simple docstring"""
								super().__init__(**_snake_case	)

								A_				 =						TFRegNetXLayer if config.layer_type == "x" else TFRegNetYLayer
								A_				 =						[
								    # downsampling is done in the first layer with stride of 2
								    layer(_snake_case       ,   _snake_case       ,   _snake_case       ,   stride=_snake_case       ,   name="layers.0"	),
								    *[layer(_snake_case       ,   _snake_case       ,   _snake_case       ,   name=F'layers.{i+1}'	) for i in range(depth - 1	)],
								]






			def      lowerCamelCase__     (				self						:					Dict       ,   _snake_case						:					str	)      -> List[Any]:







								"""simple docstring"""
								for layer_module in self.layers:
													A_				 =						layer_module(_snake_case	)
								return hidden_state





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




			"""simple docstring"""







			def __init__(				self						:					Union[str, Any]       ,   _snake_case						:					RegNetConfig       ,   **_snake_case						:					int	)      -> List[Any]:







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






			def      lowerCamelCase__     (				self						:					Any       ,   _snake_case						:					tf.Tensor       ,   _snake_case						:					bool = False       ,   _snake_case						:					bool = True	)      -> TFBaseModelOutputWithNoAttention:







								"""simple docstring"""
								A_				 =						() if output_hidden_states else None

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

													A_				 =						stage_module(_snake_case	)

								if output_hidden_states:
													A_				 =						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=_snake_case       ,   hidden_states=_snake_case	)





@keras_serializable
class __lowerCAmelCase				(					tf.keras.layers.Layer      ):




			"""simple docstring"""







			snake_case	      =				RegNetConfig




			def __init__(				self						:					Optional[int]       ,   _snake_case						:					Optional[Any]       ,   **_snake_case						:					List[Any]	)      -> Any:







								"""simple docstring"""
								super().__init__(**_snake_case	)
								A_				 =						config
								A_				 =						TFRegNetEmbeddings(_snake_case       ,   name="embedder"	)
								A_				 =						TFRegNetEncoder(_snake_case       ,   name="encoder"	)
								A_				 =						tf.keras.layers.GlobalAveragePoolingaD(keepdims=_snake_case       ,   name="pooler"	)






			@unpack_inputs
			def      lowerCamelCase__     (				self						:					Union[str, Any]       ,   _snake_case						:					tf.Tensor       ,   _snake_case						:					Optional[bool] = None       ,   _snake_case						:					Optional[bool] = None       ,   _snake_case						:					bool = False       ,   )      -> TFBaseModelOutputWithPoolingAndNoAttention:







								"""simple docstring"""
								A_				 =						(
								    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
								)
								A_				 =						return_dict if return_dict is not None else self.config.use_return_dict

								A_				 =						self.embedder(_snake_case       ,   training=_snake_case	)

								A_				 =						self.encoder(
								    _snake_case       ,   output_hidden_states=_snake_case       ,   return_dict=_snake_case       ,   training=_snake_case	)

								A_				 =						encoder_outputs[0]
								A_				 =						self.pooler(_snake_case	)

								# Change to NCHW output format have uniformity in the modules
								A_				 =						tf.transpose(_snake_case       ,   perm=(0, 3, 1, 2)	)
								A_				 =						tf.transpose(_snake_case       ,   perm=(0, 3, 1, 2)	)

								# Change the other hidden state outputs to NCHW as well
								if output_hidden_states:
													A_				 =						tuple([tf.transpose(_snake_case       ,   perm=(0, 3, 1, 2)	) for h in encoder_outputs[1]]	)

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

								return TFBaseModelOutputWithPoolingAndNoAttention(
								    last_hidden_state=_snake_case       ,   pooler_output=_snake_case       ,   hidden_states=hidden_states if output_hidden_states else encoder_outputs.hidden_states       ,   )





class __lowerCAmelCase				(					_lowercase      ):




			"""simple docstring"""







			snake_case	      =				RegNetConfig
			snake_case	      =				"regnet"
			snake_case	      =				"pixel_values"




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







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





UpperCamelCase_					:						Dict				= R'''
    Parameters:
    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.
        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 [`~TFPreTrainedModel.from_pretrained`] method to load the model weights.
'''

UpperCamelCase_					:						Optional[int]				= R'''
    Args:
        pixel_values (`tf.Tensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`ConveNextImageProcessor.__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.
'''



@add_start_docstrings(
    "The bare RegNet model outputting raw features without any specific head on top."     ,				_lowercase     ,				)
class __lowerCAmelCase				(					_lowercase      ):




			"""simple docstring"""







			def __init__(				self						:					Optional[Any]       ,   _snake_case						:					RegNetConfig       ,   *_snake_case						:					Any       ,   **_snake_case						:					int	)      -> int:







								"""simple docstring"""
								super().__init__(_snake_case       ,   *_snake_case       ,   **_snake_case	)
								A_				 =						TFRegNetMainLayer(_snake_case       ,   name="regnet"	)






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







								"""simple docstring"""
								A_				 =						(
								    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
								)
								A_				 =						return_dict if return_dict is not None else self.config.use_return_dict

								A_				 =						self.regnet(
								    pixel_values=_snake_case       ,   output_hidden_states=_snake_case       ,   return_dict=_snake_case       ,   training=_snake_case       ,   )
								if not return_dict:
													return (outputs[0],) + outputs[1:]

								return TFBaseModelOutputWithPoolingAndNoAttention(
								    last_hidden_state=outputs.last_hidden_state       ,   pooler_output=outputs.pooler_output       ,   hidden_states=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     ,				)
class __lowerCAmelCase				(					_lowercase     ,				_lowercase      ):




			"""simple docstring"""







			def __init__(				self						:					int       ,   _snake_case						:					RegNetConfig       ,   *_snake_case						:					Optional[int]       ,   **_snake_case						:					Tuple	)      -> Dict:







								"""simple docstring"""
								super().__init__(_snake_case       ,   *_snake_case       ,   **_snake_case	)
								A_				 =						config.num_labels
								A_				 =						TFRegNetMainLayer(_snake_case       ,   name="regnet"	)
								# classification head
								A_				 =						[
								    tf.keras.layers.Flatten(),
								    tf.keras.layers.Dense(config.num_labels       ,   name="classifier.1"	) if config.num_labels > 0 else tf.identity,
								]






			@unpack_inputs
			@add_start_docstrings_to_model_forward(_snake_case	)
			@add_code_sample_docstrings(
			    checkpoint=_IMAGE_CLASS_CHECKPOINT       ,   output_type=_snake_case       ,   config_class=_CONFIG_FOR_DOC       ,   expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT       ,   )
			def      lowerCamelCase__     (				self						:					Optional[int]       ,   _snake_case						:					tf.Tensor = None       ,   _snake_case						:					tf.Tensor = None       ,   _snake_case						:					bool = None       ,   _snake_case						:					bool = None       ,   _snake_case						:					Optional[Any]=False       ,   )      -> Union[TFSequenceClassifierOutput, Tuple[tf.Tensor]]:







								"""simple docstring"""
								A_				 =						(
								    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
								)
								A_				 =						return_dict if return_dict is not None else self.config.use_return_dict

								A_				 =						self.regnet(
								    _snake_case       ,   output_hidden_states=_snake_case       ,   return_dict=_snake_case       ,   training=_snake_case	)

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

								A_				 =						self.classifier[0](_snake_case	)
								A_				 =						self.classifier[1](_snake_case	)

								A_				 =						None if labels is None else self.hf_compute_loss(labels=_snake_case       ,   logits=_snake_case	)

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

								return TFSequenceClassifierOutput(loss=_snake_case       ,   logits=_snake_case       ,   hidden_states=outputs.hidden_states	)






"""simple docstring"""





import hashlib
import unittest
from typing import Dict

import numpy as np

from transformers import (
    MODEL_FOR_MASK_GENERATION_MAPPING,
    TF_MODEL_FOR_MASK_GENERATION_MAPPING,
    is_vision_available,
    pipeline,
)
from transformers.pipelines import MaskGenerationPipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_vision,
    slow,
)


if is_vision_available():
		from PIL import Image
else:



		class __lowerCAmelCase				:




					"""simple docstring"""







					@staticmethod
					def      lowerCamelCase__     (				*_snake_case						:					int       ,   **_snake_case						:					Optional[Any]	)      -> str:







										"""simple docstring"""
										pass
def 							A_     (__a				):

					'''simple docstring'''





					A_				 =						hashlib.mda(image.tobytes()				)
					return m.hexdigest()[:10]
def 							A_     (__a				):

					'''simple docstring'''





					A_				 =						np.array(__a				)
					A_				 =						npimg.shape
					return {"hash": hashimage(__a				), "shape": shape}




@is_pipeline_test
@require_vision
@require_torch
class __lowerCAmelCase				(					unittest.TestCase      ):




			"""simple docstring"""







			snake_case	      =				dict(
			    (list(MODEL_FOR_MASK_GENERATION_MAPPING.items()      ) if MODEL_FOR_MASK_GENERATION_MAPPING else [])      )
			snake_case	      =				dict(
			    (list(TF_MODEL_FOR_MASK_GENERATION_MAPPING.items()      ) if TF_MODEL_FOR_MASK_GENERATION_MAPPING else [])      )




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







								"""simple docstring"""
								A_				 =						MaskGenerationPipeline(model=_snake_case       ,   image_processor=_snake_case	)
								return image_segmenter, [
								    "./tests/fixtures/tests_samples/COCO/000000039769.png",
								    "./tests/fixtures/tests_samples/COCO/000000039769.png",
								]




			def      lowerCamelCase__     (				self						:					int       ,   _snake_case						:					int       ,   _snake_case						:					Optional[Any]	)      -> Dict:







								"""simple docstring"""
								pass




			@require_tf
			@unittest.skip("Image segmentation not implemented in TF"	)
			def      lowerCamelCase__     (				self						:					Optional[Any]	)      -> Tuple:







								"""simple docstring"""
								pass




			@slow
			@require_torch
			def      lowerCamelCase__     (				self						:					Tuple	)      -> int:







								"""simple docstring"""
								A_				 =						pipeline("mask-generation"       ,   model="facebook/sam-vit-huge"	)

								A_				 =						image_segmenter("http://images.cocodataset.org/val2017/000000039769.jpg"       ,   points_per_batch=256	)

								# Shortening by hashing
								A_				 =						[]
								for i, o in enumerate(outputs["masks"]	):
													new_outupt += [{"mask": mask_to_test_readable(_snake_case	), "scores": outputs["scores"][i]}]

								# fmt: off
								self.assertEqual(
								    nested_simplify(_snake_case       ,   decimals=4	)       ,   [
								        {"mask": {"hash": "115ad19f5f", "shape": (480, 640)}, "scores": 1.0_4_4_4},
								        {"mask": {"hash": "6affa964c6", "shape": (480, 640)}, "scores": 1.0_2_1},
								        {"mask": {"hash": "dfe28a0388", "shape": (480, 640)}, "scores": 1.0_1_6_7},
								        {"mask": {"hash": "c0a5f4a318", "shape": (480, 640)}, "scores": 1.0_1_3_2},
								        {"mask": {"hash": "fe8065c197", "shape": (480, 640)}, "scores": 1.0_0_5_3},
								        {"mask": {"hash": "e2d0b7a0b7", "shape": (480, 640)}, "scores": 0.9_9_6_7},
								        {"mask": {"hash": "453c7844bd", "shape": (480, 640)}, "scores": 0.9_9_3},
								        {"mask": {"hash": "3d44f2926d", "shape": (480, 640)}, "scores": 0.9_9_0_9},
								        {"mask": {"hash": "64033ddc3f", "shape": (480, 640)}, "scores": 0.9_8_7_9},
								        {"mask": {"hash": "801064ff79", "shape": (480, 640)}, "scores": 0.9_8_3_4},
								        {"mask": {"hash": "6172f276ef", "shape": (480, 640)}, "scores": 0.9_7_1_6},
								        {"mask": {"hash": "b49e60e084", "shape": (480, 640)}, "scores": 0.9_6_1_2},
								        {"mask": {"hash": "a811e775fd", "shape": (480, 640)}, "scores": 0.9_5_9_9},
								        {"mask": {"hash": "a6a8ebcf4b", "shape": (480, 640)}, "scores": 0.9_5_5_2},
								        {"mask": {"hash": "9d8257e080", "shape": (480, 640)}, "scores": 0.9_5_3_2},
								        {"mask": {"hash": "32de6454a8", "shape": (480, 640)}, "scores": 0.9_5_1_6},
								        {"mask": {"hash": "af3d4af2c8", "shape": (480, 640)}, "scores": 0.9_4_9_9},
								        {"mask": {"hash": "3c6db475fb", "shape": (480, 640)}, "scores": 0.9_4_8_3},
								        {"mask": {"hash": "c290813fb9", "shape": (480, 640)}, "scores": 0.9_4_6_4},
								        {"mask": {"hash": "b6f0b8f606", "shape": (480, 640)}, "scores": 0.9_4_3},
								        {"mask": {"hash": "92ce16bfdf", "shape": (480, 640)}, "scores": 0.9_4_3},
								        {"mask": {"hash": "c749b25868", "shape": (480, 640)}, "scores": 0.9_4_0_8},
								        {"mask": {"hash": "efb6cab859", "shape": (480, 640)}, "scores": 0.9_3_3_5},
								        {"mask": {"hash": "1ff2eafb30", "shape": (480, 640)}, "scores": 0.9_3_2_6},
								        {"mask": {"hash": "788b798e24", "shape": (480, 640)}, "scores": 0.9_2_6_2},
								        {"mask": {"hash": "abea804f0e", "shape": (480, 640)}, "scores": 0.8_9_9_9},
								        {"mask": {"hash": "7b9e8ddb73", "shape": (480, 640)}, "scores": 0.8_9_8_6},
								        {"mask": {"hash": "cd24047c8a", "shape": (480, 640)}, "scores": 0.8_9_8_4},
								        {"mask": {"hash": "6943e6bcbd", "shape": (480, 640)}, "scores": 0.8_8_7_3},
								        {"mask": {"hash": "b5f47c9191", "shape": (480, 640)}, "scores": 0.8_8_7_1}
								    ]       ,   )
								# fmt: on






			@require_torch
			@slow
			def      lowerCamelCase__     (				self						:					List[Any]	)      -> Optional[int]:







								"""simple docstring"""
								A_				 =						"facebook/sam-vit-huge"
								A_				 =						pipeline("mask-generation"       ,   model=_snake_case	)

								A_				 =						image_segmenter(
								    "http://images.cocodataset.org/val2017/000000039769.jpg"       ,   pred_iou_thresh=1       ,   points_per_batch=256	)

								# Shortening by hashing
								A_				 =						[]
								for i, o in enumerate(outputs["masks"]	):
													new_outupt += [{"mask": mask_to_test_readable(_snake_case	), "scores": outputs["scores"][i]}]

								self.assertEqual(
								    nested_simplify(_snake_case       ,   decimals=4	)       ,   [
								        {"mask": {"hash": "115ad19f5f", "shape": (480, 640)}, "scores": 1.0_4_4_4},
								        {"mask": {"hash": "6affa964c6", "shape": (480, 640)}, "scores": 1.0_2_1_0},
								        {"mask": {"hash": "dfe28a0388", "shape": (480, 640)}, "scores": 1.0_1_6_7},
								        {"mask": {"hash": "c0a5f4a318", "shape": (480, 640)}, "scores": 1.0_1_3_2},
								        {"mask": {"hash": "fe8065c197", "shape": (480, 640)}, "scores": 1.0_0_5_3},
								    ]       ,   )




