


import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


_snake_case  :	Tuple			      =       {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

_snake_case  :	List[Any]			      =       {
    "vocab_file": {
        "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt",
    },
    "tokenizer_file": {
        "unc-nlp/lxmert-base-uncased": (
            "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json"
        ),
    },
}

_snake_case  :	Tuple			      =       {
    "unc-nlp/lxmert-base-uncased": 512,
}

_snake_case  :	List[str]			      =       {
    "unc-nlp/lxmert-base-uncased": {"do_lower_case": True},
}

class        a	(_lowerCAmelCase   ):




							"""simple docstring"""


							__UpperCAmelCase					:							Any  						=						VOCAB_FILES_NAMES
							__UpperCAmelCase					:							int  						=						PRETRAINED_VOCAB_FILES_MAP
							__UpperCAmelCase					:							Tuple  						=						PRETRAINED_INIT_CONFIGURATION
							__UpperCAmelCase					:							List[Any]  						=						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							__UpperCAmelCase					:							Dict  						=						LxmertTokenizer

							def __init__(							self :						Any					,			lowerCamelCase :						Optional[Any]=None					,			lowerCamelCase :						Optional[int]=None					,			lowerCamelCase :						List[str]=True					,			lowerCamelCase :						Tuple="[UNK]"					,			lowerCamelCase :						List[str]="[SEP]"					,			lowerCamelCase :						Optional[Any]="[PAD]"					,			lowerCamelCase :						str="[CLS]"					,			lowerCamelCase :						Optional[int]="[MASK]"					,			lowerCamelCase :						Optional[int]=True					,			lowerCamelCase :						Optional[Any]=None					,			**lowerCamelCase :						Optional[int]					,			)			->					Union[str, Any]:
														super().__init__(
														    lowerCamelCase					,			tokenizer_file=lowerCamelCase					,			do_lower_case=lowerCamelCase					,			unk_token=lowerCamelCase					,			sep_token=lowerCamelCase					,			pad_token=lowerCamelCase					,			cls_token=lowerCamelCase					,			mask_token=lowerCamelCase					,			tokenize_chinese_chars=lowerCamelCase					,			strip_accents=lowerCamelCase					,			**lowerCamelCase					,			)

														__snake_case	:    str											=     json.loads(self.backend_tokenizer.normalizer.__getstate__()       )
														if (
														    normalizer_state.get("lowercase"					,			lowerCamelCase       ) != do_lower_case
														    or normalizer_state.get("strip_accents"					,			lowerCamelCase       ) != strip_accents
														    or normalizer_state.get("handle_chinese_chars"					,			lowerCamelCase       ) != tokenize_chinese_chars
														):
																					__snake_case	:    Optional[Any]											=     getattr(lowerCamelCase					,			normalizer_state.pop("type"       )       )
																					__snake_case	:    Optional[Any]											=     do_lower_case
																					__snake_case	:    int											=     strip_accents
																					__snake_case	:    List[Any]											=     tokenize_chinese_chars
																					__snake_case	:    str											=     normalizer_class(**lowerCamelCase       )

														__snake_case	:    Union[str, Any]											=     do_lower_case

							def 					__snake_case      (							self :						Any					,			lowerCamelCase :						Any					,			lowerCamelCase :						Optional[int]=None       )			->					List[Any]:
														__snake_case	:    Tuple											=     [self.cls_token_id] + token_ids_a + [self.sep_token_id]

														if token_ids_a:
																					output += token_ids_a + [self.sep_token_id]

														return output

							def 					__snake_case      (							self :						str					,			lowerCamelCase :						List[int]					,			lowerCamelCase :						Optional[List[int]] = None       )			->					List[int]:
														__snake_case	:    List[Any]											=     [self.sep_token_id]
														__snake_case	:    Union[str, Any]											=     [self.cls_token_id]
														if token_ids_a is None:
																					return len(cls + token_ids_a + sep       ) * [0]
														return len(cls + token_ids_a + sep       ) * [0] + len(token_ids_a + sep       ) * [1]






							def 					__snake_case      (							self :						int					,			lowerCamelCase :						str					,			lowerCamelCase :						Optional[str] = None       )			->					Tuple[str]:
														__snake_case	:    Any											=     self._tokenizer.model.save(lowerCamelCase					,			name=lowerCamelCase       )
														return tuple(lowerCamelCase       )





import collections
import inspect
import unittest

from transformers import FocalNetConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
			import torch
			from torch import nn

			from transformers import (
			    FocalNetBackbone,
			    FocalNetForImageClassification,
			    FocalNetForMaskedImageModeling,
			    FocalNetModel,
			)
			from transformers.models.focalnet.modeling_focalnet import FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
			from PIL import Image

			from transformers import AutoImageProcessor

class        a	:




							"""simple docstring"""


							def __init__(							self :						Union[str, Any]					,			lowerCamelCase :						str					,			lowerCamelCase :						Tuple=13					,			lowerCamelCase :						Tuple=32					,			lowerCamelCase :						Any=2					,			lowerCamelCase :						Union[str, Any]=3					,			lowerCamelCase :						Tuple=16					,			lowerCamelCase :						Any=[32, 64, 128]					,			lowerCamelCase :						str=[1, 2, 1]					,			lowerCamelCase :						Union[str, Any]=[2, 2, 4]					,			lowerCamelCase :						Union[str, Any]=2					,			lowerCamelCase :						Optional[int]=2.0					,			lowerCamelCase :						Tuple=True					,			lowerCamelCase :						Optional[int]=0.0					,			lowerCamelCase :						List[str]=0.0					,			lowerCamelCase :						Dict=0.1					,			lowerCamelCase :						Optional[int]="gelu"					,			lowerCamelCase :						Any=False					,			lowerCamelCase :						Any=True					,			lowerCamelCase :						str=0.02					,			lowerCamelCase :						Tuple=1E-5					,			lowerCamelCase :						str=True					,			lowerCamelCase :						Optional[Any]=None					,			lowerCamelCase :						List[str]=True					,			lowerCamelCase :						Union[str, Any]=10					,			lowerCamelCase :						Any=8					,			lowerCamelCase :						List[str]=["stage1", "stage2"]					,			lowerCamelCase :						Optional[int]=[1, 2]					,			)			->					Optional[int]:
														__snake_case	:    Any											=     parent
														__snake_case	:    int											=     batch_size
														__snake_case	:    Optional[int]											=     image_size
														__snake_case	:    int											=     patch_size
														__snake_case	:    Any											=     num_channels
														__snake_case	:    List[Any]											=     embed_dim
														__snake_case	:    str											=     hidden_sizes
														__snake_case	:    int											=     depths
														__snake_case	:    Any											=     num_heads
														__snake_case	:    Any											=     window_size
														__snake_case	:    Optional[Any]											=     mlp_ratio
														__snake_case	:    Any											=     qkv_bias
														__snake_case	:    List[Any]											=     hidden_dropout_prob
														__snake_case	:    Dict											=     attention_probs_dropout_prob
														__snake_case	:    Tuple											=     drop_path_rate
														__snake_case	:    Tuple											=     hidden_act
														__snake_case	:    Optional[int]											=     use_absolute_embeddings
														__snake_case	:    Optional[int]											=     patch_norm
														__snake_case	:    int											=     layer_norm_eps
														__snake_case	:    Any											=     initializer_range
														__snake_case	:    Any											=     is_training
														__snake_case	:    Tuple											=     scope
														__snake_case	:    Tuple											=     use_labels
														__snake_case	:    Any											=     type_sequence_label_size
														__snake_case	:    Dict											=     encoder_stride
														__snake_case	:    Union[str, Any]											=     out_features
														__snake_case	:    Union[str, Any]											=     out_indices

							def 					__snake_case      (							self :						Optional[Any]       )			->					str:
														__snake_case	:    List[Any]											=     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]       )

														__snake_case	:    Optional[Any]											=     None
														if self.use_labels:
																					__snake_case	:    Tuple											=     ids_tensor([self.batch_size]					,			self.type_sequence_label_size       )

														__snake_case	:    Optional[Any]											=     self.get_config()

														return config, pixel_values, labels

							def 					__snake_case      (							self :						Union[str, Any]       )			->					List[Any]:
														return FocalNetConfig(
														    image_size=self.image_size					,			patch_size=self.patch_size					,			num_channels=self.num_channels					,			embed_dim=self.embed_dim					,			hidden_sizes=self.hidden_sizes					,			depths=self.depths					,			num_heads=self.num_heads					,			window_size=self.window_size					,			mlp_ratio=self.mlp_ratio					,			qkv_bias=self.qkv_bias					,			hidden_dropout_prob=self.hidden_dropout_prob					,			attention_probs_dropout_prob=self.attention_probs_dropout_prob					,			drop_path_rate=self.drop_path_rate					,			hidden_act=self.hidden_act					,			use_absolute_embeddings=self.use_absolute_embeddings					,			path_norm=self.patch_norm					,			layer_norm_eps=self.layer_norm_eps					,			initializer_range=self.initializer_range					,			encoder_stride=self.encoder_stride					,			out_features=self.out_features					,			out_indices=self.out_indices					,			)

							def 					__snake_case      (							self :						Optional[int]					,			lowerCamelCase :						Optional[int]					,			lowerCamelCase :						Dict					,			lowerCamelCase :						str       )			->					str:
														__snake_case	:    Tuple											=     FocalNetModel(config=lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()
														__snake_case	:    List[str]											=     model(lowerCamelCase       )

														__snake_case	:    Tuple											=     ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths       ) - 1))
														__snake_case	:    Optional[Any]											=     int(config.embed_dim * 2 ** (len(config.depths       ) - 1)       )

														self.parent.assertEqual(result.last_hidden_state.shape					,			(self.batch_size, expected_seq_len, expected_dim)       )

							def 					__snake_case      (							self :						Tuple					,			lowerCamelCase :						Optional[Any]					,			lowerCamelCase :						int					,			lowerCamelCase :						List[Any]       )			->					Optional[int]:
														__snake_case	:    Union[str, Any]											=     FocalNetBackbone(config=lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()
														__snake_case	:    int											=     model(lowerCamelCase       )

														# verify feature maps
														self.parent.assertEqual(len(result.feature_maps       )					,			len(config.out_features       )       )
														self.parent.assertListEqual(list(result.feature_maps[0].shape       )					,			[self.batch_size, self.image_size, 8, 8]       )

														# verify channels
														self.parent.assertEqual(len(model.channels       )					,			len(config.out_features       )       )
														self.parent.assertListEqual(model.channels					,			config.hidden_sizes[:-1]       )

														# verify backbone works with out_features=None
														__snake_case	:    Dict											=     None
														__snake_case	:    Any											=     FocalNetBackbone(config=lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()
														__snake_case	:    Optional[int]											=     model(lowerCamelCase       )

														# verify feature maps
														self.parent.assertEqual(len(result.feature_maps       )					,			1       )
														self.parent.assertListEqual(list(result.feature_maps[0].shape       )					,			[self.batch_size, self.image_size * 2, 4, 4]       )

														# verify channels
														self.parent.assertEqual(len(model.channels       )					,			1       )
														self.parent.assertListEqual(model.channels					,			[config.hidden_sizes[-1]]       )

							def 					__snake_case      (							self :						Any					,			lowerCamelCase :						Optional[Any]					,			lowerCamelCase :						List[Any]					,			lowerCamelCase :						Any       )			->					Optional[int]:
														__snake_case	:    List[Any]											=     FocalNetForMaskedImageModeling(config=lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()
														__snake_case	:    List[str]											=     model(lowerCamelCase       )
														self.parent.assertEqual(
														    result.reconstruction.shape					,			(self.batch_size, self.num_channels, self.image_size, self.image_size)       )

														# test greyscale images
														__snake_case	:    List[str]											=     1
														__snake_case	:    Any											=     FocalNetForMaskedImageModeling(lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()

														__snake_case	:    Optional[Any]											=     floats_tensor([self.batch_size, 1, self.image_size, self.image_size]       )
														__snake_case	:    int											=     model(lowerCamelCase       )
														self.parent.assertEqual(result.reconstruction.shape					,			(self.batch_size, 1, self.image_size, self.image_size)       )

							def 					__snake_case      (							self :						str					,			lowerCamelCase :						Dict					,			lowerCamelCase :						Any					,			lowerCamelCase :						str       )			->					Optional[Any]:
														__snake_case	:    Tuple											=     self.type_sequence_label_size
														__snake_case	:    List[Any]											=     FocalNetForImageClassification(lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()
														__snake_case	:    Optional[Any]											=     model(lowerCamelCase					,			labels=lowerCamelCase       )
														self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.type_sequence_label_size)       )

														# test greyscale images
														__snake_case	:    Optional[int]											=     1
														__snake_case	:    str											=     FocalNetForImageClassification(lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()

														__snake_case	:    Optional[Any]											=     floats_tensor([self.batch_size, 1, self.image_size, self.image_size]       )
														__snake_case	:    Optional[Any]											=     model(lowerCamelCase       )
														self.parent.assertEqual(result.logits.shape					,			(self.batch_size, self.type_sequence_label_size)       )






							def 					__snake_case      (							self :						Optional[int]       )			->					Optional[int]:
														__snake_case	:    str											=     self.prepare_config_and_inputs()

														__snake_case				,    __snake_case				,    __snake_case	:    List[str]											=     config_and_inputs
														__snake_case	:    Union[str, Any]											=     {"pixel_values": pixel_values}
														return config, inputs_dict

@require_torch
class        a	(_lowerCAmelCase  ,       _lowerCAmelCase  ,       unittest.TestCase   ):




							"""simple docstring"""


							__UpperCAmelCase					:							int  						=						(
							    (
							        FocalNetModel,
							        FocalNetForImageClassification,
							        FocalNetForMaskedImageModeling,
							        FocalNetBackbone,
							    )
							    if is_torch_available()
							    else ()
							)
							__UpperCAmelCase					:							Optional[int]  						=						(
							    {"feature-extraction": FocalNetModel, "image-classification": FocalNetForImageClassification}
							    if is_torch_available()
							    else {}
							)
							__UpperCAmelCase					:							List[str]  						=						False

							__UpperCAmelCase					:							str  						=						False
							__UpperCAmelCase					:							List[Any]  						=						False
							__UpperCAmelCase					:							Optional[int]  						=						False
							__UpperCAmelCase					:							List[str]  						=						False

							def 					__snake_case      (							self :						List[str]       )			->					Tuple:
														__snake_case	:    Optional[Any]											=     FocalNetModelTester(self       )
														__snake_case	:    int											=     ConfigTester(self					,			config_class=lowerCamelCase					,			embed_dim=37					,			has_text_modality=lowerCamelCase       )

							def 					__snake_case      (							self :						Optional[int]       )			->					int:
														self.create_and_test_config_common_properties()
														self.config_tester.create_and_test_config_to_json_string()
														self.config_tester.create_and_test_config_to_json_file()
														self.config_tester.create_and_test_config_from_and_save_pretrained()
														self.config_tester.create_and_test_config_with_num_labels()
														self.config_tester.check_config_can_be_init_without_params()
														self.config_tester.check_config_arguments_init()

							def 					__snake_case      (							self :						str       )			->					Tuple:
														return

							def 					__snake_case      (							self :						Union[str, Any]       )			->					str:
														__snake_case	:    Optional[int]											=     self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_model(*lowerCamelCase       )

							def 					__snake_case      (							self :						str       )			->					int:
														__snake_case	:    Optional[int]											=     self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_backbone(*lowerCamelCase       )

							def 					__snake_case      (							self :						List[str]       )			->					Optional[int]:
														__snake_case	:    Tuple											=     self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_masked_image_modeling(*lowerCamelCase       )

							def 					__snake_case      (							self :						str       )			->					List[str]:
														__snake_case	:    Optional[int]											=     self.model_tester.prepare_config_and_inputs()
														self.model_tester.create_and_check_for_image_classification(*lowerCamelCase       )

							@unittest.skip(reason="FocalNet does not use inputs_embeds"       )
							def 					__snake_case      (							self :						Dict       )			->					List[str]:
														pass

							@unittest.skip(reason="FocalNet does not use feedforward chunking"       )
							def 					__snake_case      (							self :						str       )			->					int:
														pass

							def 					__snake_case      (							self :						Optional[int]       )			->					Tuple:
														__snake_case				,    __snake_case	:    str											=     self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes[:-1]:
																					__snake_case	:    Dict											=     model_class(lowerCamelCase       )
																					self.assertIsInstance(model.get_input_embeddings()					,			(nn.Module)       )
																					__snake_case	:    Any											=     model.get_output_embeddings()
																					self.assertTrue(x is None or isinstance(lowerCamelCase					,			nn.Linear       )       )

							def 					__snake_case      (							self :						List[str]       )			->					Optional[int]:
														__snake_case				,    __snake_case	:    Dict											=     self.model_tester.prepare_config_and_inputs_for_common()

														for model_class in self.all_model_classes[:-1]:
																					__snake_case	:    List[str]											=     model_class(lowerCamelCase       )
																					__snake_case	:    Optional[Any]											=     inspect.signature(model.forward       )
																					# signature.parameters is an OrderedDict => so arg_names order is deterministic
																					__snake_case	:    List[Any]											=     [*signature.parameters.keys()]

																					__snake_case	:    Tuple											=     ["pixel_values"]
																					self.assertListEqual(arg_names[:1]					,			lowerCamelCase       )

							def 					__snake_case      (							self :						Optional[int]					,			lowerCamelCase :						List[str]					,			lowerCamelCase :						Tuple					,			lowerCamelCase :						List[Any]					,			lowerCamelCase :						Union[str, Any]       )			->					str:
														__snake_case	:    Tuple											=     model_class(lowerCamelCase       )
														model.to(lowerCamelCase       )
														model.eval()

														with torch.no_grad():
																					__snake_case	:    List[Any]											=     model(**self._prepare_for_class(lowerCamelCase					,			lowerCamelCase       )       )

														__snake_case	:    List[str]											=     outputs.hidden_states

														__snake_case	:    Tuple											=     getattr(
														    self.model_tester					,			"expected_num_hidden_layers"					,			len(self.model_tester.depths       ) + 1       )
														self.assertEqual(len(lowerCamelCase       )					,			lowerCamelCase       )

														# FocalNet has a different seq_length
														__snake_case	:    Tuple											=     (
														    config.patch_size
														    if isinstance(config.patch_size					,			collections.abc.Iterable       )
														    else (config.patch_size, config.patch_size)
														)

														__snake_case	:    int											=     (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

														self.assertListEqual(
														    list(hidden_states[0].shape[-2:]       )					,			[num_patches, self.model_tester.embed_dim]					,			)

														__snake_case	:    List[Any]											=     outputs.reshaped_hidden_states
														self.assertEqual(len(lowerCamelCase       )					,			lowerCamelCase       )

														__snake_case				,    __snake_case				,    __snake_case				,    __snake_case	:    Tuple											=     reshaped_hidden_states[0].shape
														__snake_case	:    Optional[int]											=     (
														    reshaped_hidden_states[0].view(lowerCamelCase					,			lowerCamelCase					,			height * width       ).permute(0					,			2					,			1       )
														)
														self.assertListEqual(
														    list(reshaped_hidden_states.shape[-2:]       )					,			[num_patches, self.model_tester.embed_dim]					,			)

							def 					__snake_case      (							self :						Tuple       )			->					int:
														__snake_case				,    __snake_case	:    Any											=     self.model_tester.prepare_config_and_inputs_for_common()

														__snake_case	:    Dict											=     (
														    self.model_tester.image_size
														    if isinstance(self.model_tester.image_size					,			collections.abc.Iterable       )
														    else (self.model_tester.image_size, self.model_tester.image_size)
														)

														for model_class in self.all_model_classes[:-1]:
																					__snake_case	:    Optional[Any]											=     True
																					self.check_hidden_states_output(lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase       )

																					# check that output_hidden_states also work using config
																					del inputs_dict["output_hidden_states"]
																					__snake_case	:    Dict											=     True

																					self.check_hidden_states_output(lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase       )

							def 					__snake_case      (							self :						Optional[int]       )			->					Any:
														__snake_case				,    __snake_case	:    Union[str, Any]											=     self.model_tester.prepare_config_and_inputs_for_common()
														__snake_case	:    Optional[int]											=     3

														__snake_case	:    List[str]											=     (
														    self.model_tester.image_size
														    if isinstance(self.model_tester.image_size					,			collections.abc.Iterable       )
														    else (self.model_tester.image_size, self.model_tester.image_size)
														)
														__snake_case	:    Any											=     (
														    config.patch_size
														    if isinstance(config.patch_size					,			collections.abc.Iterable       )
														    else (config.patch_size, config.patch_size)
														)

														__snake_case	:    Dict											=     image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
														__snake_case	:    List[Any]											=     image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

														for model_class in self.all_model_classes[:-1]:
																					__snake_case	:    List[str]											=     True
																					self.check_hidden_states_output(lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase					,			(padded_height, padded_width)       )

																					# check that output_hidden_states also work using config
																					del inputs_dict["output_hidden_states"]
																					__snake_case	:    Tuple											=     True
																					self.check_hidden_states_output(lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase					,			(padded_height, padded_width)       )

							@slow
							def 					__snake_case      (							self :						List[Any]       )			->					Union[str, Any]:
														for model_name in FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																					__snake_case	:    List[str]											=     FocalNetModel.from_pretrained(lowerCamelCase       )
																					self.assertIsNotNone(lowerCamelCase       )






							def 					__snake_case      (							self :						Tuple       )			->					List[Any]:
														__snake_case				,    __snake_case	:    str											=     self.model_tester.prepare_config_and_inputs_for_common()

														__snake_case	:    Optional[Any]											=     _config_zero_init(lowerCamelCase       )
														for model_class in self.all_model_classes:
																					__snake_case	:    Tuple											=     model_class(config=lowerCamelCase       )
																					for name, param in model.named_parameters():
																												if "embeddings" not in name and param.requires_grad:
																																			self.assertIn(
																																			    ((param.data.mean() * 1E9).round() / 1E9).item()					,			[0.0, 1.0]					,			msg=F'Parameter {name} of model {model_class} seems not properly initialized'					,			)

@require_vision
@require_torch
class        a	(unittest.TestCase   ):




							"""simple docstring"""


							@cached_property
							def 					__snake_case      (							self :						Union[str, Any]       )			->					List[Any]:
														# TODO update organization
														return AutoImageProcessor.from_pretrained("microsoft/focalnet-tiny"       ) if is_vision_available() else None






							@slow
							def 					__snake_case      (							self :						int       )			->					Optional[int]:
														__snake_case	:    List[str]											=     FocalNetForImageClassification.from_pretrained("microsoft/focalnet-tiny"       ).to(lowerCamelCase       )
														__snake_case	:    str											=     self.default_image_processor

														__snake_case	:    Dict											=     Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"       )
														__snake_case	:    Optional[Any]											=     image_processor(images=lowerCamelCase					,			return_tensors="pt"       ).to(lowerCamelCase       )

														# forward pass
														with torch.no_grad():
																					__snake_case	:    int											=     model(**lowerCamelCase       )

														# verify the logits
														__snake_case	:    List[str]											=     torch.Size((1, 1000)       )
														self.assertEqual(outputs.logits.shape					,			lowerCamelCase       )
														__snake_case	:    Optional[int]											=     torch.tensor([0.21_66, -0.43_68, 0.21_91]       ).to(lowerCamelCase       )
														self.assertTrue(torch.allclose(outputs.logits[0, :3]					,			lowerCamelCase					,			atol=1E-4       )       )
														self.assertTrue(outputs.logits.argmax(dim=-1       ).item()					,			281       )

@require_torch
class        a	(_lowerCAmelCase  ,       unittest.TestCase   ):




							"""simple docstring"""


							__UpperCAmelCase					:							Tuple  						=						(FocalNetBackbone,) if is_torch_available() else ()
							__UpperCAmelCase					:							Dict  						=						FocalNetConfig

							__UpperCAmelCase					:							Any  						=						False

							def 					__snake_case      (							self :						str       )			->					List[str]:
														__snake_case	:    Tuple											=     FocalNetModelTester(self       )

