





'''simple docstring'''







import argparse

import torch

from transformers import (
    EncodecConfig,
    EncodecFeatureExtractor,
    EncodecModel,
    logging,
)


# checkpoints downloaded from:
# https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th
# https://huggingface.co/facebook/musicgen-small/resolve/main/compression_state_dict.bin
# https://dl.fbaipublicfiles.com/encodec/v0/encodec_48khz-7e698e3e.th


logging.set_verbosity_info()
_lowercase       						=			logging.get_logger('transformers.models.encodec')

_lowercase       						=			{
    'quantizer.vq.layers.*._codebook.inited': 'quantizer.layers.*.codebook.inited',
    'quantizer.vq.layers.*._codebook.cluster_size': 'quantizer.layers.*.codebook.cluster_size',
    'quantizer.vq.layers.*._codebook.embed': 'quantizer.layers.*.codebook.embed',
    'quantizer.vq.layers.*._codebook.embed_avg': 'quantizer.layers.*.codebook.embed_avg',
}
_lowercase       						=			{
    'encoder.model.0.conv.conv': 'encoder.layers.0.conv',
    'encoder.model.1.block.1.conv.conv': 'encoder.layers.1.block.1.conv',
    'encoder.model.1.block.3.conv.conv': 'encoder.layers.1.block.3.conv',
    'encoder.model.1.shortcut.conv.conv': 'encoder.layers.1.shortcut.conv',
    'encoder.model.3.conv.conv': 'encoder.layers.3.conv',
    'encoder.model.4.block.1.conv.conv': 'encoder.layers.4.block.1.conv',
    'encoder.model.4.block.3.conv.conv': 'encoder.layers.4.block.3.conv',
    'encoder.model.4.shortcut.conv.conv': 'encoder.layers.4.shortcut.conv',
    'encoder.model.6.conv.conv': 'encoder.layers.6.conv',
    'encoder.model.7.block.1.conv.conv': 'encoder.layers.7.block.1.conv',
    'encoder.model.7.block.3.conv.conv': 'encoder.layers.7.block.3.conv',
    'encoder.model.7.shortcut.conv.conv': 'encoder.layers.7.shortcut.conv',
    'encoder.model.9.conv.conv': 'encoder.layers.9.conv',
    'encoder.model.10.block.1.conv.conv': 'encoder.layers.10.block.1.conv',
    'encoder.model.10.block.3.conv.conv': 'encoder.layers.10.block.3.conv',
    'encoder.model.10.shortcut.conv.conv': 'encoder.layers.10.shortcut.conv',
    'encoder.model.12.conv.conv': 'encoder.layers.12.conv',
    'encoder.model.13.lstm': 'encoder.layers.13.lstm',
    'encoder.model.15.conv.conv': 'encoder.layers.15.conv',
}
_lowercase       						=			{
    'encoder.model.0.conv.norm': 'encoder.layers.0.norm',
    'encoder.model.1.block.1.conv.norm': 'encoder.layers.1.block.1.norm',
    'encoder.model.1.block.3.conv.norm': 'encoder.layers.1.block.3.norm',
    'encoder.model.1.shortcut.conv.norm': 'encoder.layers.1.shortcut.norm',
    'encoder.model.3.conv.norm': 'encoder.layers.3.norm',
    'encoder.model.4.block.1.conv.norm': 'encoder.layers.4.block.1.norm',
    'encoder.model.4.block.3.conv.norm': 'encoder.layers.4.block.3.norm',
    'encoder.model.4.shortcut.conv.norm': 'encoder.layers.4.shortcut.norm',
    'encoder.model.6.conv.norm': 'encoder.layers.6.norm',
    'encoder.model.7.block.1.conv.norm': 'encoder.layers.7.block.1.norm',
    'encoder.model.7.block.3.conv.norm': 'encoder.layers.7.block.3.norm',
    'encoder.model.7.shortcut.conv.norm': 'encoder.layers.7.shortcut.norm',
    'encoder.model.9.conv.norm': 'encoder.layers.9.norm',
    'encoder.model.10.block.1.conv.norm': 'encoder.layers.10.block.1.norm',
    'encoder.model.10.block.3.conv.norm': 'encoder.layers.10.block.3.norm',
    'encoder.model.10.shortcut.conv.norm': 'encoder.layers.10.shortcut.norm',
    'encoder.model.12.conv.norm': 'encoder.layers.12.norm',
    'encoder.model.15.conv.norm': 'encoder.layers.15.norm',
}
_lowercase       						=			{
    'decoder.model.0.conv.conv': 'decoder.layers.0.conv',
    'decoder.model.1.lstm': 'decoder.layers.1.lstm',
    'decoder.model.3.convtr.convtr': 'decoder.layers.3.conv',
    'decoder.model.4.block.1.conv.conv': 'decoder.layers.4.block.1.conv',
    'decoder.model.4.block.3.conv.conv': 'decoder.layers.4.block.3.conv',
    'decoder.model.4.shortcut.conv.conv': 'decoder.layers.4.shortcut.conv',
    'decoder.model.6.convtr.convtr': 'decoder.layers.6.conv',
    'decoder.model.7.block.1.conv.conv': 'decoder.layers.7.block.1.conv',
    'decoder.model.7.block.3.conv.conv': 'decoder.layers.7.block.3.conv',
    'decoder.model.7.shortcut.conv.conv': 'decoder.layers.7.shortcut.conv',
    'decoder.model.9.convtr.convtr': 'decoder.layers.9.conv',
    'decoder.model.10.block.1.conv.conv': 'decoder.layers.10.block.1.conv',
    'decoder.model.10.block.3.conv.conv': 'decoder.layers.10.block.3.conv',
    'decoder.model.10.shortcut.conv.conv': 'decoder.layers.10.shortcut.conv',
    'decoder.model.12.convtr.convtr': 'decoder.layers.12.conv',
    'decoder.model.13.block.1.conv.conv': 'decoder.layers.13.block.1.conv',
    'decoder.model.13.block.3.conv.conv': 'decoder.layers.13.block.3.conv',
    'decoder.model.13.shortcut.conv.conv': 'decoder.layers.13.shortcut.conv',
    'decoder.model.15.conv.conv': 'decoder.layers.15.conv',
}
_lowercase       						=			{
    'decoder.model.0.conv.norm': 'decoder.layers.0.norm',
    'decoder.model.3.convtr.norm': 'decoder.layers.3.norm',
    'decoder.model.4.block.1.conv.norm': 'decoder.layers.4.block.1.norm',
    'decoder.model.4.block.3.conv.norm': 'decoder.layers.4.block.3.norm',
    'decoder.model.4.shortcut.conv.norm': 'decoder.layers.4.shortcut.norm',
    'decoder.model.6.convtr.norm': 'decoder.layers.6.norm',
    'decoder.model.7.block.1.conv.norm': 'decoder.layers.7.block.1.norm',
    'decoder.model.7.block.3.conv.norm': 'decoder.layers.7.block.3.norm',
    'decoder.model.7.shortcut.conv.norm': 'decoder.layers.7.shortcut.norm',
    'decoder.model.9.convtr.norm': 'decoder.layers.9.norm',
    'decoder.model.10.block.1.conv.norm': 'decoder.layers.10.block.1.norm',
    'decoder.model.10.block.3.conv.norm': 'decoder.layers.10.block.3.norm',
    'decoder.model.10.shortcut.conv.norm': 'decoder.layers.10.shortcut.norm',
    'decoder.model.12.convtr.norm': 'decoder.layers.12.norm',
    'decoder.model.13.block.1.conv.norm': 'decoder.layers.13.block.1.norm',
    'decoder.model.13.block.3.conv.norm': 'decoder.layers.13.block.3.norm',
    'decoder.model.13.shortcut.conv.norm': 'decoder.layers.13.shortcut.norm',
    'decoder.model.15.conv.norm': 'decoder.layers.15.norm',
}
_lowercase       						=			{
    **MAPPING_QUANTIZER,
    **MAPPING_ENCODER,
    **MAPPING_DECODER,
}
_lowercase       						=			{
    **MAPPING_QUANTIZER,
    **MAPPING_ENCODER,
    **MAPPING_ENCODER_48K,
    **MAPPING_DECODER,
    **MAPPING_DECODER_48K,
}
_lowercase       						=			[]
_lowercase       						=			[]

def    __UpperCamelCase	(	a    : Any					,   a    : List[Any]					,   a    : List[Any]					,   a    : List[str]					,   a    : str     ) ->Any:
	for attribute in key.split('''.'''     ):
		snake_case				=			getattr(__UpperCamelCase					,   __UpperCamelCase     )

	if weight_type is not None:
		snake_case				=			getattr(__UpperCamelCase					,   __UpperCamelCase     ).shape
	else:
		snake_case				=			hf_pointer.shape

	if hf_shape != value.shape:
		raise ValueError(
		    f"""Shape of hf {key + '.' + weight_type if weight_type is not None else ''} is {hf_shape}, but should be"""
		    f""" {value.shape} for {full_name}"""     )

	if weight_type == "weight":
		snake_case				=			value
	elif weight_type == "weight_g":
		snake_case				=			value
	elif weight_type == "weight_v":
		snake_case				=			value
	elif weight_type == "bias":
		snake_case				=			value
	elif weight_type == "running_mean":
		snake_case				=			value
	elif weight_type == "running_var":
		snake_case				=			value
	elif weight_type == "num_batches_tracked":
		snake_case				=			value
	elif weight_type == "weight_ih_l0":
		snake_case				=			value
	elif weight_type == "weight_hh_l0":
		snake_case				=			value
	elif weight_type == "bias_ih_l0":
		snake_case				=			value
	elif weight_type == "bias_hh_l0":
		snake_case				=			value
	elif weight_type == "weight_ih_l1":
		snake_case				=			value
	elif weight_type == "weight_hh_l1":
		snake_case				=			value
	elif weight_type == "bias_ih_l1":
		snake_case				=			value
	elif weight_type == "bias_hh_l1":
		snake_case				=			value
	else:
		snake_case				=			value

	logger.info(f"""{key + ('.' + weight_type if weight_type is not None else '')} was initialized from {full_name}."""     )

def    __UpperCamelCase	(	a    : Dict					,   a    : str     ) ->Union[str, Any]:
	for key in ignore_keys:
		if key.endswith('''.*'''     ):
			if name.startswith(key[:-1]     ):
				return True
		elif ".*." in key:
			snake_case				,		snake_case				=			key.split('''.*.'''     )
			if prefix in name and suffix in name:
				return True
		elif key in name:
			return True
	return False

def    __UpperCamelCase	(	a    : Tuple					,   a    : Tuple					,   a    : Union[str, Any]     ) ->Any:
	snake_case				=			[]

	if model_name == "encodec_24khz" or "encodec_32khz":
		snake_case				=			MAPPING_24K
	elif model_name == "encodec_48khz":
		snake_case				=			MAPPING_48K
	else:
		raise ValueError(f"""Unsupported model: {model_name}"""     )

	for name, value in orig_dict.items():
		if should_ignore(__UpperCamelCase					,   __UpperCamelCase     ):
			logger.info(f"""{name} was ignored"""     )
			continue

		snake_case				=			False
		for key, mapped_key in MAPPING.items():
			if "*" in key:
				snake_case				,		snake_case				=			key.split('''.*.'''     )
				if prefix in name and suffix in name:
					snake_case				=			suffix

			if key in name:
				# HACK otherwise .embed gets initialized with .embed_avg too
				if key.endswith('''embed'''     ) and name.endswith('''embed_avg'''     ):
					continue

				snake_case				=			True
				if "*" in mapped_key:
					snake_case				=			name.split(__UpperCamelCase     )[0].split('''.'''     )[-2]
					snake_case				=			mapped_key.replace('''*'''					,   __UpperCamelCase     )
				if "weight_g" in name:
					snake_case				=			'''weight_g'''
				elif "weight_v" in name:
					snake_case				=			'''weight_v'''
				elif "weight_ih_l0" in name:
					snake_case				=			'''weight_ih_l0'''
				elif "weight_hh_l0" in name:
					snake_case				=			'''weight_hh_l0'''
				elif "bias_ih_l0" in name:
					snake_case				=			'''bias_ih_l0'''
				elif "bias_hh_l0" in name:
					snake_case				=			'''bias_hh_l0'''
				elif "weight_ih_l1" in name:
					snake_case				=			'''weight_ih_l1'''
				elif "weight_hh_l1" in name:
					snake_case				=			'''weight_hh_l1'''
				elif "bias_ih_l1" in name:
					snake_case				=			'''bias_ih_l1'''
				elif "bias_hh_l1" in name:
					snake_case				=			'''bias_hh_l1'''
				elif "bias" in name:
					snake_case				=			'''bias'''
				elif "weight" in name:
					snake_case				=			'''weight'''
				elif "running_mean" in name:
					snake_case				=			'''running_mean'''
				elif "running_var" in name:
					snake_case				=			'''running_var'''
				elif "num_batches_tracked" in name:
					snake_case				=			'''num_batches_tracked'''
				else:
					snake_case				=			None
				set_recursively(__UpperCamelCase					,   __UpperCamelCase					,   __UpperCamelCase					,   __UpperCamelCase					,   __UpperCamelCase     )
			continue
		if not is_used:
			unused_weights.append(__UpperCamelCase     )

	logger.warning(f"""Unused weights: {unused_weights}"""     )

@torch.no_grad()
def    __UpperCamelCase	(	a    : List[str]					,   a    : int					,   a    : Optional[int]					,   a    : Dict=None					,   a    : List[Any]=None					,   ) ->int:
	if config_path is not None:
		snake_case				=			EncodecConfig.from_pretrained(__UpperCamelCase     )
	else:
		snake_case				=			EncodecConfig()

	if model_name == "encodec_24khz":
		pass  # config is already correct
	elif model_name == "encodec_32khz":
		snake_case				=			[8, 5, 4, 4]
		snake_case				=			[2.2]
		snake_case				=			64
		snake_case				=			3_2000
		snake_case				=			2048
		snake_case				=			False
		snake_case				=			False
		snake_case				=			False
	elif model_name == "encodec_48khz":
		snake_case				=			[8, 5, 4, 2]
		snake_case				=			[3.0, 6.0, 12.0, 24.0]
		snake_case				=			4_8000
		snake_case				=			2
		snake_case				=			False
		snake_case				=			'''time_group_norm'''
		snake_case				=			True
		snake_case				=			1.0
		snake_case				=			0.01
	else:
		raise ValueError(f"""Unknown model name: {model_name}"""     )

	snake_case				=			EncodecModel(__UpperCamelCase     )

	snake_case				=			EncodecFeatureExtractor(
	    feature_size=config.audio_channels					,   sampling_rate=config.sampling_rate					,   chunk_length_s=config.chunk_length_s					,   overlap=config.overlap					,   )
	feature_extractor.save_pretrained(__UpperCamelCase     )

	snake_case				=			torch.load(__UpperCamelCase     )
	if "best_state" in original_checkpoint:
		# we might have a training state saved, in which case discard the yaml results and just retain the weights
		snake_case				=			original_checkpoint['''best_state''']
	recursively_load_weights(__UpperCamelCase					,   __UpperCamelCase					,   __UpperCamelCase     )
	model.save_pretrained(__UpperCamelCase     )

	if repo_id:
		print('''Pushing to the hub...'''     )
		feature_extractor.push_to_hub(__UpperCamelCase     )
		model.push_to_hub(__UpperCamelCase     )


if __name__ == "__main__":
			_lowercase       						=			argparse.ArgumentParser()
			parser.add_argument(
			    '--model',
			    default='encodec_24khz',
			    type=str,
			    help='The model to convert. Should be one of \'encodec_24khz\', \'encodec_32khz\', \'encodec_48khz\'.',
			)
			parser.add_argument('--checkpoint_path', required=True, default=None, type=str, help='Path to original checkpoint')
			parser.add_argument('--config_path', default=None, type=str, help='Path to hf config.json of model to convert')
			parser.add_argument(
			    '--pytorch_dump_folder_path', required=True, default=None, type=str, help='Path to the output PyTorch model.'
			)
			parser.add_argument(
			    '--push_to_hub', default=None, type=str, help='Where to upload the converted model on the 🤗 hub.'
			)

			_lowercase       						=			parser.parse_args()
			convert_checkpoint(
			    args.model,
			    args.checkpoint_path,
			    args.pytorch_dump_folder_path,
			    args.config_path,
			    args.push_to_hub,
			)








'''simple docstring'''







from __future__ import annotations

import inspect
import unittest

from transformers import ViTConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
   import tensorflow as tf

   from transformers import TFViTForImageClassification, TFViTModel


if is_vision_available():
   from PIL import Image

   from transformers import ViTImageProcessor
class 			_lowercase						:







     def __init__( self    ,   A__    ,   A__=13    ,   A__=30    ,   A__=2    ,   A__=3    ,   A__=True    ,   A__=True    ,   A__=32    ,   A__=2    ,   A__=4    ,   A__=37    ,   A__="gelu"    ,   A__=0.1    ,   A__=0.1    ,   A__=10    ,   A__=0.0_2    ,   A__=3    ,   A__=None    ,   ) ->	List[Any]:
      snake_case				=			parent
      snake_case				=			batch_size
      snake_case				=			image_size
      snake_case				=			patch_size
      snake_case				=			num_channels
      snake_case				=			is_training
      snake_case				=			use_labels
      snake_case				=			hidden_size
      snake_case				=			num_hidden_layers
      snake_case				=			num_attention_heads
      snake_case				=			intermediate_size
      snake_case				=			hidden_act
      snake_case				=			hidden_dropout_prob
      snake_case				=			attention_probs_dropout_prob
      snake_case				=			type_sequence_label_size
      snake_case				=			initializer_range
      snake_case				=			scope

      # in ViT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
      snake_case				=			(image_size // patch_size) ** 2
      snake_case				=			num_patches + 1







     def     UpperCamelCase			( self    ) ->	int:
      snake_case				=			floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]    )

      snake_case				=			None
      if self.use_labels:
       snake_case				=			ids_tensor([self.batch_size]    ,   self.type_sequence_label_size    )

      snake_case				=			self.get_config()

      return config, pixel_values, labels







     def     UpperCamelCase			( self    ) ->	int:
      return ViTConfig(
          image_size=self.image_size    ,   patch_size=self.patch_size    ,   num_channels=self.num_channels    ,   hidden_size=self.hidden_size    ,   num_hidden_layers=self.num_hidden_layers    ,   num_attention_heads=self.num_attention_heads    ,   intermediate_size=self.intermediate_size    ,   hidden_act=self.hidden_act    ,   hidden_dropout_prob=self.hidden_dropout_prob    ,   attention_probs_dropout_prob=self.attention_probs_dropout_prob    ,   is_decoder=A__    ,   initializer_range=self.initializer_range    ,   )







     def     UpperCamelCase			( self    ,   A__    ,   A__    ,   A__    ) ->	Union[str, Any]:
      snake_case				=			TFViTModel(config=A__    )
      snake_case				=			model(A__    ,   training=A__    )
      self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, self.seq_length, self.hidden_size)    )

      # Test with an image with different size than the one specified in config.
      snake_case				=			self.image_size // 2
      snake_case				=			pixel_values[:, :, :image_size, :image_size]
      snake_case				=			model(A__    ,   interpolate_pos_encoding=A__    ,   training=A__    )
      snake_case				=			(image_size // self.patch_size) ** 2 + 1
      self.parent.assertEqual(result.last_hidden_state.shape    ,   (self.batch_size, seq_length, self.hidden_size)    )







     def     UpperCamelCase			( self    ,   A__    ,   A__    ,   A__    ) ->	Optional[int]:
      snake_case				=			self.type_sequence_label_size
      snake_case				=			TFViTForImageClassification(A__    )
      snake_case				=			model(A__    ,   labels=A__    ,   training=A__    )
      self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.type_sequence_label_size)    )

      # Test with an image with different size than the one specified in config.
      snake_case				=			self.image_size // 2
      snake_case				=			pixel_values[:, :, :image_size, :image_size]
      snake_case				=			model(A__    ,   interpolate_pos_encoding=A__    ,   training=A__    )
      self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.type_sequence_label_size)    )

      # test greyscale images
      snake_case				=			1
      snake_case				=			TFViTForImageClassification(A__    )
      snake_case				=			floats_tensor([self.batch_size, 1, self.image_size, self.image_size]    )
      snake_case				=			model(A__    )
      self.parent.assertEqual(result.logits.shape    ,   (self.batch_size, self.type_sequence_label_size)    )







     def     UpperCamelCase			( self    ) ->	Union[str, Any]:
      snake_case				=			self.prepare_config_and_inputs()
      snake_case				,		snake_case				,		snake_case				=			config_and_inputs
      snake_case				=			{'''pixel_values''': pixel_values}
      return config, inputs_dict




@require_tf
class 			_lowercase						(       __a				,		__a				,		unittest.TestCase					):
     _UpperCAmelCase										=					(TFViTModel, TFViTForImageClassification) if is_tf_available() else ()
     _UpperCAmelCase										=					(
         {'''feature-extraction''': TFViTModel, '''image-classification''': TFViTForImageClassification}
         if is_tf_available()
         else {}
     )

     _UpperCAmelCase										=					False
     _UpperCAmelCase										=					False
     _UpperCAmelCase										=					False







     def     UpperCamelCase			( self    ) ->	List[Any]:
      snake_case				=			TFViTModelTester(self    )
      snake_case				=			ConfigTester(self    ,   config_class=A__    ,   has_text_modality=A__    ,   hidden_size=37    )







     def     UpperCamelCase			( self    ) ->	int:
      self.config_tester.run_common_tests()







     @unittest.skip(reason='''ViT does not use inputs_embeds'''    )
     def     UpperCamelCase			( self    ) ->	int:
      pass







     @unittest.skip(reason='''ViT does not use inputs_embeds'''    )
     def     UpperCamelCase			( self    ) ->	str:
      pass







     def     UpperCamelCase			( self    ) ->	Union[str, Any]:
      snake_case				,		snake_case				=			self.model_tester.prepare_config_and_inputs_for_common()

      for model_class in self.all_model_classes:
       snake_case				=			model_class(A__    )
       self.assertIsInstance(model.get_input_embeddings()    ,   (tf.keras.layers.Layer)    )
       snake_case				=			model.get_output_embeddings()
       self.assertTrue(x is None or isinstance(A__    ,   tf.keras.layers.Layer    )    )







     def     UpperCamelCase			( self    ) ->	List[Any]:
      snake_case				,		snake_case				=			self.model_tester.prepare_config_and_inputs_for_common()

      for model_class in self.all_model_classes:
       snake_case				=			model_class(A__    )
       snake_case				=			inspect.signature(model.call    )
       # signature.parameters is an OrderedDict => so arg_names order is deterministic
       snake_case				=			[*signature.parameters.keys()]

       snake_case				=			['''pixel_values''']
       self.assertListEqual(arg_names[:1]    ,   A__    )







     def     UpperCamelCase			( self    ) ->	Union[str, Any]:
      snake_case				=			self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*A__    )







     def     UpperCamelCase			( self    ) ->	Optional[Any]:
      snake_case				=			self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_image_classification(*A__    )







     @slow
     def     UpperCamelCase			( self    ) ->	Any:
      snake_case				=			TFViTModel.from_pretrained('''google/vit-base-patch16-224'''    )
      self.assertIsNotNone(A__    )




def    __UpperCamelCase	(	) ->Any:
 snake_case				=			Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''     )
 return image






@require_tf
@require_vision
class 			_lowercase						(       unittest.TestCase					):







     @cached_property
     def     UpperCamelCase			( self    ) ->	Optional[int]:
      return ViTImageProcessor.from_pretrained('''google/vit-base-patch16-224'''    ) if is_vision_available() else None







     @slow
     def     UpperCamelCase			( self    ) ->	Dict:
      snake_case				=			TFViTForImageClassification.from_pretrained('''google/vit-base-patch16-224'''    )

      snake_case				=			self.default_image_processor
      snake_case				=			prepare_img()
      snake_case				=			image_processor(images=A__    ,   return_tensors='''tf'''    )

      # forward pass
      snake_case				=			model(**A__    )

      # verify the logits
      snake_case				=			tf.TensorShape((1, 10_00)    )
      self.assertEqual(outputs.logits.shape    ,   A__    )

      snake_case				=			tf.constant([-0.2_7_4_4, 0.8_2_1_5, -0.0_8_3_6]    )

      tf.debugging.assert_near(outputs.logits[0, :3]    ,   A__    ,   atol=1e-4    )

