






"""simple docstring"""




import argparse
import collections

import numpy as np
import torch
from flax import traverse_util
from tax import checkpoints

from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration
from transformers.utils import logging


logging.set_verbosity_info()

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  return params[F"""{prefix}/{prefix}/relpos_bias/rel_embedding"""][:, i, :]

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__="attention"				):



  '''simple docstring'''
  _a  :       str             =	np.ascontiguousarray(params[F"""{prefix}/{prefix}/{layer_name}/key/kernel"""][:, i, :, :]				)
  _a  :       Optional[int]             =	k_tmp.reshape(k_tmp.shape[0]     ,   k_tmp.shape[1] * k_tmp.shape[2]				)
  _a  :       Dict             =	np.ascontiguousarray(params[F"""{prefix}/{prefix}/{layer_name}/out/kernel"""][:, i, :, :]				)
  _a  :       Optional[int]             =	o_tmp.reshape(o_tmp.shape[0] * o_tmp.shape[1]     ,   o_tmp.shape[2]				)
  _a  :       str             =	np.ascontiguousarray(params[F"""{prefix}/{prefix}/{layer_name}/query/kernel"""][:, i, :, :]				)
  _a  :       List[Any]             =	q_tmp.reshape(q_tmp.shape[0]     ,   q_tmp.shape[1] * q_tmp.shape[2]				)
  _a  :       Union[str, Any]             =	np.ascontiguousarray(params[F"""{prefix}/{prefix}/{layer_name}/value/kernel"""][:, i, :, :]				)
  _a  :       Tuple             =	v_tmp.reshape(v_tmp.shape[0]     ,   v_tmp.shape[1] * v_tmp.shape[2]				)
  return k, o, q, v

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__=False				):



  '''simple docstring'''
  if split_mlp_wi:
    _a  :       List[Any]             =	params[F"""{prefix}/{prefix}/mlp/wi_0/kernel"""][:, i, :]
    _a  :       List[Any]             =	params[F"""{prefix}/{prefix}/mlp/wi_1/kernel"""][:, i, :]
    _a  :       Optional[int]             =	(wi_a, wi_a)
  else:
    _a  :       str             =	params[F"""{prefix}/{prefix}/mlp/wi/kernel"""][:, i, :]

  _a  :       List[Any]             =	params[F"""{prefix}/{prefix}/mlp/wo/kernel"""][:, i, :]
  return wi, wo

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  return params[F"""{prefix}/{prefix}/{layer_name}/scale"""][:, i]

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   *, UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__ = False				):



  '''simple docstring'''
  _a  :       Optional[Any]             =	traverse_util.flatten_dict(variables["""target"""]				)
  _a  :       List[str]             =	{"""/""".join(UpperCamelCase__				): v for k, v in old.items()}

  # v1.1 models have a gated GeLU with wi_0 and wi_1 instead of wi
  _a  :       str             =	"""encoder/encoder/mlp/wi_0/kernel""" in old
  print("""Split MLP:"""     ,   UpperCamelCase__				)

  _a  :       int             =	collections.OrderedDict()

  # Shared embeddings.
  _a  :       Optional[Any]             =	old["""token_embedder/embedding"""]

  # Encoder.
  for i in range(UpperCamelCase__				):
    # Block i, layer 0 (Self Attention).
    _a  :       Any             =	tax_layer_norm_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """encoder"""     ,   """pre_attention_layer_norm"""				)
    _a      ,  _a      ,  _a      ,  _a  :       str             =	tax_attention_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """encoder"""     ,   """attention"""				)
    _a  :       Dict             =	layer_norm
    _a  :       Tuple             =	k.T
    _a  :       Optional[int]             =	o.T
    _a  :       Tuple             =	q.T
    _a  :       str             =	v.T

    # Block i, layer 1 (MLP).
    _a  :       List[str]             =	tax_layer_norm_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """encoder"""     ,   """pre_mlp_layer_norm"""				)
    _a      ,  _a  :       int             =	tax_mlp_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """encoder"""     ,   UpperCamelCase__				)
    _a  :       List[Any]             =	layer_norm
    if split_mlp_wi:
      _a  :       Union[str, Any]             =	wi[0].T
      _a  :       Optional[int]             =	wi[1].T
    else:
      _a  :       Optional[Any]             =	wi.T
    _a  :       Any             =	wo.T
    if scalable_attention:
      # convert the rel_embedding of each layer
      _a  :       Tuple             =	tax_relpos_bias_lookup(
          UpperCamelCase__     ,   UpperCamelCase__     ,   """encoder"""				).T

  _a  :       List[Any]             =	old["""encoder/encoder_norm/scale"""]

  if not scalable_attention:
    _a  :       Tuple             =	tax_relpos_bias_lookup(
        UpperCamelCase__     ,   0     ,   """encoder"""				).T
    _a  :       Tuple             =	tax_relpos_bias_lookup(
        UpperCamelCase__     ,   0     ,   """decoder"""				).T

  if not is_encoder_only:
    # Decoder.
    for i in range(UpperCamelCase__				):
      # Block i, layer 0 (Self Attention).
      _a  :       List[Any]             =	tax_layer_norm_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""     ,   """pre_self_attention_layer_norm"""				)
      _a      ,  _a      ,  _a      ,  _a  :       Optional[Any]             =	tax_attention_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""     ,   """self_attention"""				)
      _a  :       List[Any]             =	layer_norm
      _a  :       Union[str, Any]             =	k.T
      _a  :       Optional[int]             =	o.T
      _a  :       str             =	q.T
      _a  :       List[str]             =	v.T

      # Block i, layer 1 (Cross Attention).
      _a  :       Tuple             =	tax_layer_norm_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""     ,   """pre_cross_attention_layer_norm"""				)
      _a      ,  _a      ,  _a      ,  _a  :       List[Any]             =	tax_attention_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""     ,   """encoder_decoder_attention"""				)
      _a  :       Union[str, Any]             =	layer_norm
      _a  :       Tuple             =	k.T
      _a  :       Optional[Any]             =	o.T
      _a  :       Union[str, Any]             =	q.T
      _a  :       List[Any]             =	v.T

      # Block i, layer 2 (MLP).
      _a  :       Union[str, Any]             =	tax_layer_norm_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""     ,   """pre_mlp_layer_norm"""				)
      _a      ,  _a  :       Any             =	tax_mlp_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""     ,   UpperCamelCase__				)
      _a  :       Dict             =	layer_norm
      if split_mlp_wi:
        _a  :       Union[str, Any]             =	wi[0].T
        _a  :       int             =	wi[1].T
      else:
        _a  :       Dict             =	wi.T
      _a  :       Tuple             =	wo.T

      if scalable_attention:
        # convert the rel_embedding of each layer
        _a  :       Dict             =	tax_relpos_bias_lookup(UpperCamelCase__     ,   UpperCamelCase__     ,   """decoder"""				).T

    _a  :       str             =	old["""decoder/decoder_norm/scale"""]

    # LM Head (only in v1.1 checkpoints, in v1.0 embeddings are used instead)
    if "decoder/logits_dense/kernel" in old:
      _a  :       Union[str, Any]             =	old["""decoder/logits_dense/kernel"""].T

  return new

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  _a  :       Union[str, Any]             =	collections.OrderedDict([(k, torch.from_numpy(v.copy()				)) for (k, v) in converted_params.items()]				)

  # Add what is missing.
  if "encoder.embed_tokens.weight" not in state_dict:
    _a  :       List[Any]             =	state_dict["""shared.weight"""]

  if not is_encoder_only:
    if "decoder.embed_tokens.weight" not in state_dict:
      _a  :       Optional[Any]             =	state_dict["""shared.weight"""]

    if "lm_head.weight" not in state_dict:  # For old 1.0 models.
      print("""Using shared word embeddings as lm_head."""				)
      _a  :       List[str]             =	state_dict["""shared.weight"""]

  return state_dict

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''
  _a  :       Dict             =	checkpoints.load_tax_checkpoint(UpperCamelCase__				)
  _a  :       Dict             =	convert_tax_to_pytorch(
      UpperCamelCase__     ,   num_layers=config.num_layers     ,   is_encoder_only=UpperCamelCase__     ,   scalable_attention=UpperCamelCase__				)
  _a  :       Optional[Any]             =	make_state_dict(UpperCamelCase__     ,   UpperCamelCase__				)
  model.load_state_dict(UpperCamelCase__     ,   strict=UpperCamelCase__				)

def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__ = False     ,   UpperCamelCase__ = False     ,   ):



  '''simple docstring'''
  _a  :       Dict             =	MTaConfig.from_json_file(UpperCamelCase__				)
  print(F"""Building PyTorch model from configuration: {config}"""				)
  # Non-v1.1 checkpoints could also use T5Model, but this works for all.
  # The v1.0 checkpoints will simply have an LM head that is the word embeddings.
  if is_encoder_only:
    _a  :       Optional[int]             =	UMTaEncoderModel(UpperCamelCase__				)
  else:
    _a  :       int             =	UMTaForConditionalGeneration(UpperCamelCase__				)

  # Load weights from tf checkpoint
  load_tax_weights_in_ta(UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__     ,   UpperCamelCase__				)

  # Save pytorch-model
  print(F"""Save PyTorch model to {pytorch_dump_path}"""				)
  model.save_pretrained(UpperCamelCase__				)

  # Verify that we can load the checkpoint.
  model.from_pretrained(UpperCamelCase__				)
  print("""Done"""				)


if __name__ == "__main__":
 _snake_case          =   argparse.ArgumentParser(description='Converts a native T5X checkpoint into a PyTorch checkpoint.')
 # Required parameters
 parser.add_argument(
     '--t5x_checkpoint_path', default=None, type=str, required=True, help='Path to the T5X checkpoint.'
 )
 parser.add_argument(
     '--config_file',
     default=None,
     type=str,
     required=True,
     help='The config json file corresponding to the pre-trained T5 model.\nThis specifies the model architecture.',
 )
 parser.add_argument(
     '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
 )
 parser.add_argument(
     '--is_encoder_only', action='store_true', help='Check if the model is encoder-decoder model', default=False
 )
 parser.add_argument(
     '--scalable_attention',
     action='store_true',
     help='Whether the model uses scaled attention (umt5 model)',
     default=False,
 )
 _snake_case          =   parser.parse_args()
 convert_tax_checkpoint_to_pytorch(
     args.tax_checkpoint_path,
     args.config_file,
     args.pytorch_dump_path,
     args.is_encoder_only,
     args.scalable_attention,
 )









"""simple docstring"""




import shutil
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import (
    is_pt_tf_cross_test,
    require_tf,
    require_torch,
    require_torchvision,
    require_vision,
)
from transformers.utils import is_tf_available, is_torch_available, is_vision_available


if is_vision_available():
 from PIL import Image

 from transformers import AutoProcessor, SamImageProcessor, SamProcessor

if is_torch_available():
 import torch

if is_tf_available():
 import tensorflow as tf






@require_vision
@require_torchvision
class        UpperCamelCase			(	unittest.TestCase      ):


 def _lowercase	(     self		:						List[Any]							)					->       Dict:
   _a  :       Optional[int]             =	tempfile.mkdtemp()
   _a  :       Optional[Any]             =	SamImageProcessor()
   _a  :       int             =	SamProcessor(UpperCAmelCase__							)
   processor.save_pretrained(self.tmpdirname							)


 def _lowercase	(     self		:						Tuple							,						**UpperCAmelCase__		:						Any							)					->       Any:
   return AutoProcessor.from_pretrained(self.tmpdirname							,						**UpperCAmelCase__							).image_processor


 def _lowercase	(     self		:						str							)					->       int:
   shutil.rmtree(self.tmpdirname							)


 def _lowercase	(     self		:						Tuple							)					->       Dict:
   _a  :       List[Any]             =	[np.random.randint(255							,						size=(3, 30, 400)							,						dtype=np.uinta							)]

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

   return image_inputs


 def _lowercase	(     self		:						Dict							)					->       Dict:
   _a  :       List[Any]             =	SamProcessor(image_processor=self.get_image_processor()							)
   processor.save_pretrained(self.tmpdirname							)

   _a  :       Tuple             =	self.get_image_processor(do_normalize=UpperCAmelCase__							,						padding_value=1.0							)

   _a  :       Tuple             =	SamProcessor.from_pretrained(self.tmpdirname							,						do_normalize=UpperCAmelCase__							,						padding_value=1.0							)

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


 def _lowercase	(     self		:						Union[str, Any]							)					->       Tuple:
   _a  :       Optional[Any]             =	self.get_image_processor()

   _a  :       int             =	SamProcessor(image_processor=UpperCAmelCase__							)

   _a  :       Union[str, Any]             =	self.prepare_image_inputs()

   _a  :       List[str]             =	image_processor(UpperCAmelCase__							,						return_tensors="""np"""							)
   _a  :       List[str]             =	processor(images=UpperCAmelCase__							,						return_tensors="""np"""							)

   input_feat_extract.pop("""original_sizes"""							)  # pop original_sizes as it is popped in the processor
   input_feat_extract.pop("""reshaped_input_sizes"""							)  # pop original_sizes as it is popped in the processor

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







 @require_torch
 def _lowercase	(     self		:						Optional[Any]							)					->       Optional[Any]:
   _a  :       Optional[Any]             =	self.get_image_processor()

   _a  :       Dict             =	SamProcessor(image_processor=UpperCAmelCase__							)
   _a  :       Tuple             =	[torch.ones((1, 3, 5, 5)							)]

   _a  :       Tuple             =	[[1764, 2646]]

   _a  :       Optional[int]             =	[[683, 1024]]
   _a  :       List[Any]             =	processor.post_process_masks(UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							)
   self.assertEqual(masks[0].shape							,						(1, 3, 1764, 2646)							)

   _a  :       int             =	processor.post_process_masks(
       UpperCAmelCase__							,						torch.tensor(UpperCAmelCase__							)							,						torch.tensor(UpperCAmelCase__							)							)
   self.assertEqual(masks[0].shape							,						(1, 3, 1764, 2646)							)

   # should also work with np
   _a  :       Optional[Any]             =	[np.ones((1, 3, 5, 5)							)]
   _a  :       Tuple             =	processor.post_process_masks(UpperCAmelCase__							,						np.array(UpperCAmelCase__							)							,						np.array(UpperCAmelCase__							)							)

   self.assertEqual(masks[0].shape							,						(1, 3, 1764, 2646)							)

   _a  :       List[str]             =	[[1, 0], [0, 1]]
   with self.assertRaises(UpperCAmelCase__							):
     _a  :       str             =	processor.post_process_masks(UpperCAmelCase__							,						np.array(UpperCAmelCase__							)							,						np.array(UpperCAmelCase__							)							)







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


 def _lowercase	(     self		:						Any							)					->       List[str]:
   _a  :       List[str]             =	tempfile.mkdtemp()
   _a  :       Any             =	SamImageProcessor()
   _a  :       Union[str, Any]             =	SamProcessor(UpperCAmelCase__							)
   processor.save_pretrained(self.tmpdirname							)


 def _lowercase	(     self		:						List[str]							,						**UpperCAmelCase__		:						Any							)					->       List[str]:
   return AutoProcessor.from_pretrained(self.tmpdirname							,						**UpperCAmelCase__							).image_processor


 def _lowercase	(     self		:						Optional[Any]							)					->       Union[str, Any]:
   shutil.rmtree(self.tmpdirname							)


 def _lowercase	(     self		:						Dict							)					->       List[str]:
   _a  :       List[Any]             =	[np.random.randint(255							,						size=(3, 30, 400)							,						dtype=np.uinta							)]

   _a  :       List[Any]             =	[Image.fromarray(np.moveaxis(UpperCAmelCase__							,						0							,						-1							)							) for x in image_inputs]

   return image_inputs


 def _lowercase	(     self		:						Union[str, Any]							)					->       Union[str, Any]:
   _a  :       Optional[int]             =	SamProcessor(image_processor=self.get_image_processor()							)
   processor.save_pretrained(self.tmpdirname							)

   _a  :       str             =	self.get_image_processor(do_normalize=UpperCAmelCase__							,						padding_value=1.0							)

   _a  :       Union[str, Any]             =	SamProcessor.from_pretrained(self.tmpdirname							,						do_normalize=UpperCAmelCase__							,						padding_value=1.0							)

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


 def _lowercase	(     self		:						List[Any]							)					->       str:
   _a  :       Union[str, Any]             =	self.get_image_processor()

   _a  :       Dict             =	SamProcessor(image_processor=UpperCAmelCase__							)

   _a  :       int             =	self.prepare_image_inputs()

   _a  :       List[str]             =	image_processor(UpperCAmelCase__							,						return_tensors="""np"""							)
   _a  :       List[str]             =	processor(images=UpperCAmelCase__							,						return_tensors="""np"""							)

   input_feat_extract.pop("""original_sizes"""							)  # pop original_sizes as it is popped in the processor
   input_feat_extract.pop("""reshaped_input_sizes"""							)  # pop reshaped_input_sizes as it is popped in the processor

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







 @require_tf
 def _lowercase	(     self		:						Optional[Any]							)					->       int:
   _a  :       Optional[Any]             =	self.get_image_processor()

   _a  :       Dict             =	SamProcessor(image_processor=UpperCAmelCase__							)
   _a  :       Any             =	[tf.ones((1, 3, 5, 5)							)]

   _a  :       Tuple             =	[[1764, 2646]]

   _a  :       str             =	[[683, 1024]]
   _a  :       Union[str, Any]             =	processor.post_process_masks(UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							,						return_tensors="""tf"""							)
   self.assertEqual(masks[0].shape							,						(1, 3, 1764, 2646)							)

   _a  :       Union[str, Any]             =	processor.post_process_masks(
       UpperCAmelCase__							,						tf.convert_to_tensor(UpperCAmelCase__							)							,						tf.convert_to_tensor(UpperCAmelCase__							)							,						return_tensors="""tf"""							,						)
   self.assertEqual(masks[0].shape							,						(1, 3, 1764, 2646)							)

   # should also work with np
   _a  :       List[Any]             =	[np.ones((1, 3, 5, 5)							)]
   _a  :       Optional[int]             =	processor.post_process_masks(
       UpperCAmelCase__							,						np.array(UpperCAmelCase__							)							,						np.array(UpperCAmelCase__							)							,						return_tensors="""tf"""							)

   self.assertEqual(masks[0].shape							,						(1, 3, 1764, 2646)							)

   _a  :       Dict             =	[[1, 0], [0, 1]]
   with self.assertRaises(tf.errors.InvalidArgumentError							):
     _a  :       List[Any]             =	processor.post_process_masks(
         UpperCAmelCase__							,						np.array(UpperCAmelCase__							)							,						np.array(UpperCAmelCase__							)							,						return_tensors="""tf"""							)







@require_vision
@require_torchvision
class        UpperCamelCase			(	unittest.TestCase      ):


 def _lowercase	(     self		:						str							)					->       Optional[Any]:
   _a  :       Optional[Any]             =	tempfile.mkdtemp()
   _a  :       Dict             =	SamImageProcessor()
   _a  :       List[str]             =	SamProcessor(UpperCAmelCase__							)
   processor.save_pretrained(self.tmpdirname							)


 def _lowercase	(     self		:						Any							,						**UpperCAmelCase__		:						Dict							)					->       int:
   return AutoProcessor.from_pretrained(self.tmpdirname							,						**UpperCAmelCase__							).image_processor


 def _lowercase	(     self		:						Tuple							)					->       List[Any]:
   shutil.rmtree(self.tmpdirname							)


 def _lowercase	(     self		:						str							)					->       int:
   _a  :       str             =	[np.random.randint(255							,						size=(3, 30, 400)							,						dtype=np.uinta							)]

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

   return image_inputs


 @is_pt_tf_cross_test
 def _lowercase	(     self		:						int							)					->       List[Any]:
   _a  :       Optional[Any]             =	self.get_image_processor()

   _a  :       Optional[Any]             =	SamProcessor(image_processor=UpperCAmelCase__							)
   _a  :       Tuple             =	np.random.randint(0							,						2							,						size=(1, 3, 5, 5)							).astype(np.floataa							)
   _a  :       str             =	[tf.convert_to_tensor(UpperCAmelCase__							)]
   _a  :       Optional[int]             =	[torch.tensor(UpperCAmelCase__							)]

   _a  :       Union[str, Any]             =	[[1764, 2646]]

   _a  :       List[str]             =	[[683, 1024]]
   _a  :       Optional[int]             =	processor.post_process_masks(
       UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							,						return_tensors="""tf"""							)
   _a  :       List[str]             =	processor.post_process_masks(
       UpperCAmelCase__							,						UpperCAmelCase__							,						UpperCAmelCase__							,						return_tensors="""pt"""							)

   self.assertTrue(np.all(tf_masks[0].numpy() == pt_masks[0].numpy()							)							)







 @is_pt_tf_cross_test
 def _lowercase	(     self		:						str							)					->       Optional[Any]:
   _a  :       List[Any]             =	self.get_image_processor()

   _a  :       Any             =	SamProcessor(image_processor=UpperCAmelCase__							)

   _a  :       Dict             =	self.prepare_image_inputs()

   _a  :       List[str]             =	image_processor(UpperCAmelCase__							,						return_tensors="""pt"""							)["""pixel_values"""].numpy()
   _a  :       str             =	processor(images=UpperCAmelCase__							,						return_tensors="""pt"""							)["""pixel_values"""].numpy()

   _a  :       Optional[Any]             =	image_processor(UpperCAmelCase__							,						return_tensors="""tf"""							)["""pixel_values"""].numpy()
   _a  :       Optional[int]             =	processor(images=UpperCAmelCase__							,						return_tensors="""tf"""							)["""pixel_values"""].numpy()

   self.assertTrue(np.allclose(UpperCAmelCase__							,						UpperCAmelCase__							)							)
   self.assertTrue(np.allclose(UpperCAmelCase__							,						UpperCAmelCase__							)							)
   self.assertTrue(np.allclose(UpperCAmelCase__							,						UpperCAmelCase__							)							)

