





import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import ConvNextConfig, ConvNextForImageClassification, ConvNextImageProcessor
from transformers.utils import logging


logging.set_verbosity_info()
__UpperCAmelCase						=      logging.get_logger(__name__)
def 			__UpperCamelCase				(			lowercase__	:       Optional[Any]		)	->      List[str]:
    '''simple docstring'''





    lowerCAmelCase_					:	str						=   ConvNextConfig()

    if "tiny" in checkpoint_url:
        lowerCAmelCase_					:	Dict						=   [3, 3, 9, 3]
        lowerCAmelCase_					:	List[str]						=   [96, 192, 384, 768]
    if "small" in checkpoint_url:
        lowerCAmelCase_					:	int						=   [3, 3, 27, 3]
        lowerCAmelCase_					:	Tuple						=   [96, 192, 384, 768]
    if "base" in checkpoint_url:
        lowerCAmelCase_					:	Any						=   [3, 3, 27, 3]
        lowerCAmelCase_					:	Union[str, Any]						=   [128, 256, 512, 1024]
    if "large" in checkpoint_url:
        lowerCAmelCase_					:	Union[str, Any]						=   [3, 3, 27, 3]
        lowerCAmelCase_					:	Union[str, Any]						=   [192, 384, 768, 1536]
    if "xlarge" in checkpoint_url:
        lowerCAmelCase_					:	int						=   [3, 3, 27, 3]
        lowerCAmelCase_					:	List[Any]						=   [256, 512, 1024, 2048]

    if "1k" in checkpoint_url:
        lowerCAmelCase_					:	List[Any]						=   1000
        lowerCAmelCase_					:	List[str]						=   """imagenet-1k-id2label.json"""
        lowerCAmelCase_					:	Optional[int]						=   (1, 1000)
    else:
        lowerCAmelCase_					:	int						=   21841
        lowerCAmelCase_					:	Dict						=   """imagenet-22k-id2label.json"""
        lowerCAmelCase_					:	Union[str, Any]						=   (1, 21841)

    lowerCAmelCase_					:	str						=   """huggingface/label-files"""
    lowerCAmelCase_					:	Dict						=   num_labels
    lowerCAmelCase_					:	Optional[int]						=   json.load(open(hf_hub_download(lowercase__		,    lowercase__		,    repo_type="""dataset"""		)		,    """r"""		)		)
    lowerCAmelCase_					:	Union[str, Any]						=   {int(lowercase__		): v for k, v in idalabel.items()}
    if "1k" not in checkpoint_url:
        # this dataset contains 21843 labels but the model only has 21841
        # we delete the classes as mentioned in https://github.com/google-research/big_transfer/issues/18
        del idalabel[9205]
        del idalabel[15027]
    lowerCAmelCase_					:	Tuple						=   idalabel
    lowerCAmelCase_					:	Optional[int]						=   {v: k for k, v in idalabel.items()}
    lowerCAmelCase_					:	str						=   hidden_sizes
    lowerCAmelCase_					:	int						=   depths

    return config, expected_shape
def 			__UpperCamelCase				(			lowercase__	:       Union[str, Any]		)	->      str:
    '''simple docstring'''





    if "downsample_layers.0.0" in name:
        lowerCAmelCase_					:	Optional[int]						=   name.replace("""downsample_layers.0.0"""		,    """embeddings.patch_embeddings"""		)
    if "downsample_layers.0.1" in name:
        lowerCAmelCase_					:	Union[str, Any]						=   name.replace("""downsample_layers.0.1"""		,    """embeddings.norm"""		)  # we rename to layernorm later on
    if "downsample_layers.1.0" in name:
        lowerCAmelCase_					:	List[Any]						=   name.replace("""downsample_layers.1.0"""		,    """stages.1.downsampling_layer.0"""		)
    if "downsample_layers.1.1" in name:
        lowerCAmelCase_					:	int						=   name.replace("""downsample_layers.1.1"""		,    """stages.1.downsampling_layer.1"""		)
    if "downsample_layers.2.0" in name:
        lowerCAmelCase_					:	Dict						=   name.replace("""downsample_layers.2.0"""		,    """stages.2.downsampling_layer.0"""		)
    if "downsample_layers.2.1" in name:
        lowerCAmelCase_					:	Dict						=   name.replace("""downsample_layers.2.1"""		,    """stages.2.downsampling_layer.1"""		)
    if "downsample_layers.3.0" in name:
        lowerCAmelCase_					:	int						=   name.replace("""downsample_layers.3.0"""		,    """stages.3.downsampling_layer.0"""		)
    if "downsample_layers.3.1" in name:
        lowerCAmelCase_					:	List[str]						=   name.replace("""downsample_layers.3.1"""		,    """stages.3.downsampling_layer.1"""		)
    if "stages" in name and "downsampling_layer" not in name:
        # stages.0.0. for instance should be renamed to stages.0.layers.0.
        lowerCAmelCase_					:	Union[str, Any]						=   name[: len("""stages.0"""		)] + """.layers""" + name[len("""stages.0"""		) :]
    if "stages" in name:
        lowerCAmelCase_					:	Optional[Any]						=   name.replace("""stages"""		,    """encoder.stages"""		)
    if "norm" in name:
        lowerCAmelCase_					:	str						=   name.replace("""norm"""		,    """layernorm"""		)
    if "gamma" in name:
        lowerCAmelCase_					:	int						=   name.replace("""gamma"""		,    """layer_scale_parameter"""		)
    if "head" in name:
        lowerCAmelCase_					:	str						=   name.replace("""head"""		,    """classifier"""		)

    return name
def 			__UpperCamelCase				(			)	->      int:
    '''simple docstring'''





    lowerCAmelCase_					:	Tuple						=   """http://images.cocodataset.org/val2017/000000039769.jpg"""
    lowerCAmelCase_					:	int						=   Image.open(requests.get(lowercase__		,    stream=lowercase__		).raw		)
    return im
@torch.no_grad()
def 			__UpperCamelCase				(			lowercase__	:       List[Any]		,    lowercase__	:       List[str]		)	->      Union[str, Any]:
    '''simple docstring'''





    lowerCAmelCase_		,		lowerCAmelCase_					:	List[str]						=   get_convnext_config(lowercase__		)
    # load original state_dict from URL
    lowerCAmelCase_					:	List[Any]						=   torch.hub.load_state_dict_from_url(lowercase__		)["""model"""]
    # rename keys
    for key in state_dict.copy().keys():
        lowerCAmelCase_					:	Optional[Any]						=   state_dict.pop(lowercase__		)
        lowerCAmelCase_					:	Optional[Any]						=   val
    # add prefix to all keys expect classifier head
    for key in state_dict.copy().keys():
        lowerCAmelCase_					:	List[Any]						=   state_dict.pop(lowercase__		)
        if not key.startswith("""classifier"""		):
            lowerCAmelCase_					:	List[Any]						=   """convnext.""" + key
        lowerCAmelCase_					:	Union[str, Any]						=   val

    # load HuggingFace model
    lowerCAmelCase_					:	Dict						=   ConvNextForImageClassification(lowercase__		)
    model.load_state_dict(lowercase__		)
    model.eval()

    # Check outputs on an image, prepared by ConvNextImageProcessor
    lowerCAmelCase_					:	List[Any]						=   224 if """224""" in checkpoint_url else 384
    lowerCAmelCase_					:	List[Any]						=   ConvNextImageProcessor(size=lowercase__		)
    lowerCAmelCase_					:	Tuple						=   image_processor(images=prepare_img()		,    return_tensors="""pt"""		).pixel_values

    lowerCAmelCase_					:	str						=   model(lowercase__		).logits

    # note: the logits below were obtained without center cropping
    if checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth":
        lowerCAmelCase_					:	Optional[int]						=   torch.tensor([-0.1210, -0.6605, 0.1918]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_small_1k_224_ema.pth":
        lowerCAmelCase_					:	Union[str, Any]						=   torch.tensor([-0.4473, -0.1847, -0.6365]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_1k_224_ema.pth":
        lowerCAmelCase_					:	Tuple						=   torch.tensor([0.4525, 0.7539, 0.0308]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_1k_384.pth":
        lowerCAmelCase_					:	str						=   torch.tensor([0.3561, 0.6350, -0.0384]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_1k_224_ema.pth":
        lowerCAmelCase_					:	Optional[int]						=   torch.tensor([0.4174, -0.0989, 0.1489]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_1k_384.pth":
        lowerCAmelCase_					:	Tuple						=   torch.tensor([0.2513, -0.1349, -0.1613]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_224.pth":
        lowerCAmelCase_					:	Optional[Any]						=   torch.tensor([1.2980, 0.3631, -0.1198]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_224.pth":
        lowerCAmelCase_					:	int						=   torch.tensor([1.2963, 0.1227, 0.1723]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_224.pth":
        lowerCAmelCase_					:	Dict						=   torch.tensor([1.7956, 0.8390, 0.2820]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_224.pth":
        lowerCAmelCase_					:	List[Any]						=   torch.tensor([-0.2822, -0.0502, -0.0878]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_384.pth":
        lowerCAmelCase_					:	List[Any]						=   torch.tensor([-0.5672, -0.0730, -0.4348]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_224.pth":
        lowerCAmelCase_					:	str						=   torch.tensor([0.2681, 0.2365, 0.6246]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_384.pth":
        lowerCAmelCase_					:	Tuple						=   torch.tensor([-0.2642, 0.3931, 0.5116]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_224_ema.pth":
        lowerCAmelCase_					:	Optional[Any]						=   torch.tensor([-0.6677, -0.1873, -0.8379]		)
    elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_384_ema.pth":
        lowerCAmelCase_					:	int						=   torch.tensor([-0.7749, -0.2967, -0.6444]		)
    else:
        raise ValueError(f'Unknown URL: {checkpoint_url}'		)

    assert torch.allclose(logits[0, :3]		,    lowercase__		,    atol=1E-3		)
    assert logits.shape == expected_shape

    Path(lowercase__		).mkdir(exist_ok=lowercase__		)
    print(f'Saving model to {pytorch_dump_folder_path}'		)
    model.save_pretrained(lowercase__		)
    print(f'Saving image processor to {pytorch_dump_folder_path}'		)
    image_processor.save_pretrained(lowercase__		)

    print("""Pushing model to the hub..."""		)
    lowerCAmelCase_					:	Dict						=   """convnext"""
    if "tiny" in checkpoint_url:
        model_name += "-tiny"
    elif "small" in checkpoint_url:
        model_name += "-small"
    elif "base" in checkpoint_url:
        model_name += "-base"
    elif "xlarge" in checkpoint_url:
        model_name += "-xlarge"
    elif "large" in checkpoint_url:
        model_name += "-large"
    if "224" in checkpoint_url:
        model_name += "-224"
    elif "384" in checkpoint_url:
        model_name += "-384"
    if "22k" in checkpoint_url and "1k" not in checkpoint_url:
        model_name += "-22k"
    if "22k" in checkpoint_url and "1k" in checkpoint_url:
        model_name += "-22k-1k"

    model.push_to_hub(
        repo_path_or_name=Path(lowercase__		,    lowercase__		)		,    organization="""nielsr"""		,    commit_message="""Add model"""		,    )


if __name__ == "__main__":
  __UpperCAmelCase						=      argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      '--checkpoint_url',
      default='https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth',
      type=str,
      help='URL of the original ConvNeXT checkpoint you\'d like to convert.',
  )
  parser.add_argument(
      '--pytorch_dump_folder_path',
      default=None,
      type=str,
      required=True,
      help='Path to the output PyTorch model directory.',
  )

  __UpperCAmelCase						=      parser.parse_args()
  convert_convnext_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path)









import json
import os
import random
import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import BertTokenizer, BertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_vision
from transformers.utils import IMAGE_PROCESSOR_NAME, is_vision_available


if is_vision_available():
  from PIL import Image

  from transformers import FlavaImageProcessor, FlavaProcessor
  from transformers.models.flava.image_processing_flava import (
      FLAVA_CODEBOOK_MEAN,
      FLAVA_CODEBOOK_STD,
      FLAVA_IMAGE_MEAN,
      FLAVA_IMAGE_STD,
  )

@require_vision
class 		__a							(	unittest.TestCase      ):



       def  A							(     self	:   List[str]			):
           lowerCAmelCase_					:	Dict						=   tempfile.mkdtemp()

           # fmt: off
           lowerCAmelCase_					:	Dict						=   ["""[UNK]""", """[CLS]""", """[SEP]""", """[PAD]""", """[MASK]""", """want""", """##want""", """##ed""", """wa""", """un""", """runn""", """##ing""", """,""", """low""", """lowest"""]
           # fmt: on
           lowerCAmelCase_					:	Any						=   os.path.join(self.tmpdirname					,			VOCAB_FILES_NAMES["""vocab_file"""]			)

           with open(self.vocab_file					,			"""w"""					,			encoding="""utf-8"""			) as fp:
               fp.write("""""".join([x + """\n""" for x in vocab_tokens]			)			)

           lowerCAmelCase_					:	int						=   {
               """image_mean""": FLAVA_IMAGE_MEAN,
               """image_std""": FLAVA_IMAGE_STD,
               """do_normalize""": True,
               """do_resize""": True,
               """size""": 2_24,
               """do_center_crop""": True,
               """crop_size""": 2_24,
               """input_size_patches""": 14,
               """total_mask_patches""": 75,
               """mask_group_max_patches""": None,
               """mask_group_min_patches""": 16,
               """mask_group_min_aspect_ratio""": 0.3,
               """mask_group_max_aspect_ratio""": None,
               """codebook_do_resize""": True,
               """codebook_size""": 1_12,
               """codebook_do_center_crop""": True,
               """codebook_crop_size""": 1_12,
               """codebook_do_map_pixels""": True,
               """codebook_do_normalize""": True,
               """codebook_image_mean""": FLAVA_CODEBOOK_MEAN,
               """codebook_image_std""": FLAVA_CODEBOOK_STD,
           }

           lowerCAmelCase_					:	Union[str, Any]						=   os.path.join(self.tmpdirname					,			UpperCAmelCase			)
           with open(self.image_processor_file					,			"""w"""					,			encoding="""utf-8"""			) as fp:
               json.dump(UpperCAmelCase					,			UpperCAmelCase			)



       def  A							(     self	:   Any					,			**UpperCAmelCase	:   Union[str, Any]			):
           return BertTokenizer.from_pretrained(self.tmpdirname					,			**UpperCAmelCase			)



       def  A							(     self	:   List[str]					,			**UpperCAmelCase	:   str			):
           return BertTokenizerFast.from_pretrained(self.tmpdirname					,			**UpperCAmelCase			)



       def  A							(     self	:   Any					,			**UpperCAmelCase	:   int			):
           return FlavaImageProcessor.from_pretrained(self.tmpdirname					,			**UpperCAmelCase			)



       def  A							(     self	:   Optional[int]			):
           shutil.rmtree(self.tmpdirname			)



       def  A							(     self	:   str			):
           lowerCAmelCase_					:	Union[str, Any]						=   [np.random.randint(2_55					,			size=(3, 30, 4_00)					,			dtype=np.uinta			)]

           lowerCAmelCase_					:	int						=   [Image.fromarray(np.moveaxis(UpperCAmelCase					,			0					,			-1			)			) for x in image_inputs]

           return image_inputs



       def  A							(     self	:   Tuple			):
           lowerCAmelCase_					:	str						=   self.get_tokenizer()
           lowerCAmelCase_					:	Dict						=   self.get_rust_tokenizer()
           lowerCAmelCase_					:	Optional[int]						=   self.get_image_processor()

           lowerCAmelCase_					:	str						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)
           processor_slow.save_pretrained(self.tmpdirname			)
           lowerCAmelCase_					:	List[str]						=   FlavaProcessor.from_pretrained(self.tmpdirname					,			use_fast=UpperCAmelCase			)

           lowerCAmelCase_					:	List[Any]						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)
           processor_fast.save_pretrained(self.tmpdirname			)
           lowerCAmelCase_					:	List[str]						=   FlavaProcessor.from_pretrained(self.tmpdirname			)

           self.assertEqual(processor_slow.tokenizer.get_vocab()					,			tokenizer_slow.get_vocab()			)
           self.assertEqual(processor_fast.tokenizer.get_vocab()					,			tokenizer_fast.get_vocab()			)
           self.assertEqual(tokenizer_slow.get_vocab()					,			tokenizer_fast.get_vocab()			)
           self.assertIsInstance(processor_slow.tokenizer					,			UpperCAmelCase			)
           self.assertIsInstance(processor_fast.tokenizer					,			UpperCAmelCase			)

           self.assertEqual(processor_slow.image_processor.to_json_string()					,			image_processor.to_json_string()			)
           self.assertEqual(processor_fast.image_processor.to_json_string()					,			image_processor.to_json_string()			)
           self.assertIsInstance(processor_slow.image_processor					,			UpperCAmelCase			)
           self.assertIsInstance(processor_fast.image_processor					,			UpperCAmelCase			)



       def  A							(     self	:   Any			):
           lowerCAmelCase_					:	Any						=   FlavaProcessor(tokenizer=self.get_tokenizer()					,			image_processor=self.get_image_processor()			)
           processor.save_pretrained(self.tmpdirname			)

           lowerCAmelCase_					:	Union[str, Any]						=   self.get_tokenizer(bos_token="""(BOS)"""					,			eos_token="""(EOS)"""			)
           lowerCAmelCase_					:	Optional[Any]						=   self.get_image_processor(do_normalize=UpperCAmelCase					,			padding_value=1.0			)

           lowerCAmelCase_					:	Any						=   FlavaProcessor.from_pretrained(
               self.tmpdirname					,			bos_token="""(BOS)"""					,			eos_token="""(EOS)"""					,			do_normalize=UpperCAmelCase					,			padding_value=1.0			)

           self.assertEqual(processor.tokenizer.get_vocab()					,			tokenizer_add_kwargs.get_vocab()			)
           self.assertIsInstance(processor.tokenizer					,			UpperCAmelCase			)

           self.assertEqual(processor.image_processor.to_json_string()					,			image_processor_add_kwargs.to_json_string()			)
           self.assertIsInstance(processor.image_processor					,			UpperCAmelCase			)



       def  A							(     self	:   str			):
           lowerCAmelCase_					:	Tuple						=   self.get_image_processor()
           lowerCAmelCase_					:	Union[str, Any]						=   self.get_tokenizer()

           lowerCAmelCase_					:	str						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)

           lowerCAmelCase_					:	Tuple						=   self.prepare_image_inputs()

           lowerCAmelCase_					:	List[str]						=   image_processor(UpperCAmelCase					,			return_tensors="""np"""			)
           lowerCAmelCase_					:	Tuple						=   processor(images=UpperCAmelCase					,			return_tensors="""np"""			)

           for key in input_feat_extract.keys():
               self.assertAlmostEqual(input_feat_extract[key].sum()					,			input_processor[key].sum()					,			delta=1e-2			)

           # With rest of the args
           random.seed(12_34			)
           lowerCAmelCase_					:	Optional[Any]						=   image_processor(
               UpperCAmelCase					,			return_image_mask=UpperCAmelCase					,			return_codebook_pixels=UpperCAmelCase					,			return_tensors="""np"""			)
           random.seed(12_34			)
           lowerCAmelCase_					:	Dict						=   processor(
               images=UpperCAmelCase					,			return_image_mask=UpperCAmelCase					,			return_codebook_pixels=UpperCAmelCase					,			return_tensors="""np"""			)

           for key in input_feat_extract.keys():
               self.assertAlmostEqual(input_feat_extract[key].sum()					,			input_processor[key].sum()					,			delta=1e-2			)



       def  A							(     self	:   str			):
           lowerCAmelCase_					:	Tuple						=   self.get_image_processor()
           lowerCAmelCase_					:	List[Any]						=   self.get_tokenizer()

           lowerCAmelCase_					:	str						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)

           lowerCAmelCase_					:	str						=   """lower newer"""

           lowerCAmelCase_					:	Dict						=   processor(text=UpperCAmelCase			)

           lowerCAmelCase_					:	List[Any]						=   tokenizer(UpperCAmelCase			)

           for key in encoded_tok.keys():
               self.assertListEqual(encoded_tok[key]					,			encoded_processor[key]			)



       def  A							(     self	:   Optional[Any]			):
           lowerCAmelCase_					:	Optional[int]						=   self.get_image_processor()
           lowerCAmelCase_					:	List[Any]						=   self.get_tokenizer()

           lowerCAmelCase_					:	str						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)

           lowerCAmelCase_					:	str						=   """lower newer"""
           lowerCAmelCase_					:	Any						=   self.prepare_image_inputs()

           lowerCAmelCase_					:	Optional[int]						=   processor(text=UpperCAmelCase					,			images=UpperCAmelCase			)

           self.assertListEqual(list(inputs.keys()			)					,			["""input_ids""", """token_type_ids""", """attention_mask""", """pixel_values"""]			)

           # add extra args
           lowerCAmelCase_					:	str						=   processor(text=UpperCAmelCase					,			images=UpperCAmelCase					,			return_codebook_pixels=UpperCAmelCase					,			return_image_mask=UpperCAmelCase			)

           self.assertListEqual(
               list(inputs.keys()			)					,			[
                   """input_ids""",
                   """token_type_ids""",
                   """attention_mask""",
                   """pixel_values""",
                   """codebook_pixel_values""",
                   """bool_masked_pos""",
               ]					,			)

           # test if it raises when no input is passed
           with pytest.raises(UpperCAmelCase			):
               processor()



       def  A							(     self	:   List[Any]			):
           lowerCAmelCase_					:	str						=   self.get_image_processor()
           lowerCAmelCase_					:	int						=   self.get_tokenizer()

           lowerCAmelCase_					:	Union[str, Any]						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)

           lowerCAmelCase_					:	Optional[Any]						=   [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

           lowerCAmelCase_					:	List[str]						=   processor.batch_decode(UpperCAmelCase			)
           lowerCAmelCase_					:	Tuple						=   tokenizer.batch_decode(UpperCAmelCase			)

           self.assertListEqual(UpperCAmelCase					,			UpperCAmelCase			)



       def  A							(     self	:   List[Any]			):
           lowerCAmelCase_					:	Tuple						=   self.get_image_processor()
           lowerCAmelCase_					:	Union[str, Any]						=   self.get_tokenizer()

           lowerCAmelCase_					:	int						=   FlavaProcessor(tokenizer=UpperCAmelCase					,			image_processor=UpperCAmelCase			)

           lowerCAmelCase_					:	List[str]						=   """lower newer"""
           lowerCAmelCase_					:	Dict						=   self.prepare_image_inputs()

           lowerCAmelCase_					:	Optional[int]						=   processor(text=UpperCAmelCase					,			images=UpperCAmelCase			)

           self.assertListEqual(list(inputs.keys()			)					,			processor.model_input_names			)


