'''simple docstring'''






import importlib.metadata
import warnings
from copy import deepcopy

from packaging import version

from ..utils import logging
from .import_utils import is_accelerate_available, is_bitsandbytes_available


if is_bitsandbytes_available():
   import bitsandbytes as bnb
   import torch
   import torch.nn as nn

   from ..pytorch_utils import ConvaD

if is_accelerate_available():
   from accelerate import init_empty_weights
   from accelerate.utils import find_tied_parameters

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





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			Any   ,		__snake_case							:			Tuple   ,		__snake_case							:			Optional[Any]   ,		__snake_case							:			Optional[Any]=None   ,		__snake_case							:			Optional[Any]=None				):



     if "." in tensor_name:
          _A    		=  tensor_name.split('.'				)
          for split in splits[:-1]:
               _A    		=  getattr(lowerCamelCase_   ,		lowerCamelCase_				)
               if new_module is None:
                    raise ValueError(F'{module} has no attribute {split}.'				)
               _A    		=  new_module
          _A    		=  splits[-1]

     if tensor_name not in module._parameters and tensor_name not in module._buffers:
          raise ValueError(F'{module} does not have a parameter or a buffer named {tensor_name}.'				)
     _A    		=  tensor_name in module._buffers
     _A    		=  getattr(lowerCamelCase_   ,		lowerCamelCase_				)

     if old_value.device == torch.device('meta'				) and device not in ["meta", torch.device('meta'				)] and value is None:
          raise ValueError(F'{tensor_name} is on the meta device, we need a `value` to put in on {device}.'				)

     _A    		=  False
     _A    		=  False
     if is_buffer or not is_bitsandbytes_available():
          _A    		=  False
          _A    		=  False
     else:
          _A    		=  hasattr(bnb.nn   ,		'Params4bit'				) and isinstance(module._parameters[tensor_name]   ,		bnb.nn.Paramsabit				)
          _A    		=  isinstance(module._parameters[tensor_name]   ,		bnb.nn.IntaParams				)

     if is_abit or is_abit:
          _A    		=  module._parameters[tensor_name]
          if param.device.type != "cuda":
               if value is None:
                    _A    		=  old_value.to(lowerCamelCase_				)
               elif isinstance(lowerCamelCase_   ,		torch.Tensor				):
                    _A    		=  value.to('cpu'				)
                    if value.dtype == torch.inta:
                         _A    		=  version.parse(importlib.metadata.version('bitsandbytes'				)				) > version.parse(
                             '0.37.2'				)
                         if not is_abit_serializable:
                              raise ValueError(
                                  'Detected int8 weights but the version of bitsandbytes is not compatible with int8 serialization. '
                                  'Make sure to download the latest `bitsandbytes` version. `pip install --upgrade bitsandbytes`.'				)
               else:
                    _A    		=  torch.tensor(lowerCamelCase_   ,		device='cpu'				)

               # Support models using `Conv1D` in place of `nn.Linear` (e.g. gpt2) by transposing the weight matrix prior to quantization.
               # Since weights are saved in the correct "orientation", we skip transposing when loading.
               if issubclass(module.source_cls   ,		lowerCamelCase_				) and fpaa_statistics is None:
                    _A    		=  new_value.T

               _A    		=  old_value.__dict__
               if is_abit:
                    _A    		=  bnb.nn.IntaParams(lowerCamelCase_   ,		requires_grad=lowerCamelCase_   ,		**lowerCamelCase_				).to(lowerCamelCase_				)
               elif is_abit:
                    _A    		=  bnb.nn.Paramsabit(lowerCamelCase_   ,		requires_grad=lowerCamelCase_   ,		**lowerCamelCase_				).to(lowerCamelCase_				)

               _A    		=  new_value
               if fpaa_statistics is not None:
                    setattr(module.weight   ,		'SCB'   ,		fpaa_statistics.to(lowerCamelCase_				)				)

     else:
          if value is None:
               _A    		=  old_value.to(lowerCamelCase_				)
          elif isinstance(lowerCamelCase_   ,		torch.Tensor				):
               _A    		=  value.to(lowerCamelCase_				)
          else:
               _A    		=  torch.tensor(lowerCamelCase_   ,		device=lowerCamelCase_				)

          if is_buffer:
               _A    		=  new_value
          else:
               _A    		=  nn.Parameter(lowerCamelCase_   ,		requires_grad=old_value.requires_grad				)
               _A    		=  new_value





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			Any   ,		__snake_case							:			List[Any]=None   ,		__snake_case							:			Tuple=None   ,		__snake_case							:			List[str]=None   ,		__snake_case							:			Tuple=False				):



     for name, module in model.named_children():
          if current_key_name is None:
               _A    		=  []
          current_key_name.append(lowerCamelCase_				)

          if (isinstance(lowerCamelCase_   ,		nn.Linear				) or isinstance(lowerCamelCase_   ,		lowerCamelCase_				)) and name not in modules_to_not_convert:
               # Check if the current key is not in the `modules_to_not_convert`
               if not any(key in '.'.join(lowerCamelCase_				) for key in modules_to_not_convert				):
                    with init_empty_weights():
                         if isinstance(lowerCamelCase_   ,		lowerCamelCase_				):
                              _A    		=  module.weight.shape
                         else:
                              _A    		=  module.in_features
                              _A    		=  module.out_features

                         if quantization_config.quantization_method() == "llm_int8":
                              _A    		=  bnb.nn.LinearabitLt(
                                  lowerCamelCase_   ,		lowerCamelCase_   ,		module.bias is not None   ,		has_fpaa_weights=quantization_config.llm_inta_has_fpaa_weight   ,		threshold=quantization_config.llm_inta_threshold   ,		)
                              _A    		=  True
                         else:
                              if (
                                  quantization_config.llm_inta_skip_modules is not None
                                  and name in quantization_config.llm_inta_skip_modules
                              ):
                                   pass
                              else:
                                   _A    		=  bnb.nn.Linearabit(
                                       lowerCamelCase_   ,		lowerCamelCase_   ,		module.bias is not None   ,		quantization_config.bnb_abit_compute_dtype   ,		compress_statistics=quantization_config.bnb_abit_use_double_quant   ,		quant_type=quantization_config.bnb_abit_quant_type   ,		)
                                   _A    		=  True
                    # Store the module class in case we need to transpose the weight later
                         _A    		=  type(lowerCamelCase_				)
                         # Force requires grad to False to avoid unexpected errors
                         model._modules[name].requires_grad_(lowerCamelCase_				)
          if len(list(module.children()				)				) > 0:
               _A    		=  _replace_with_bnb_linear(
                   lowerCamelCase_   ,		lowerCamelCase_   ,		lowerCamelCase_   ,		lowerCamelCase_   ,		has_been_replaced=lowerCamelCase_   ,		)
          # Remove the last key for recursion
          current_key_name.pop(-1				)
     return model, has_been_replaced





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			Optional[Any]   ,		__snake_case							:			List[Any]=None   ,		__snake_case							:			str=None   ,		__snake_case							:			str=None				):
     _A    		=  ["""lm_head"""] if modules_to_not_convert is None else modules_to_not_convert
     _A    		=  _replace_with_bnb_linear(
         lowerCamelCase_   ,		lowerCamelCase_   ,		lowerCamelCase_   ,		lowerCamelCase_				)

     if not has_been_replaced:
          logger.warning(
              'You are loading your model in 8bit or 4bit but no linear modules were found in your model.'
              ' Please double check your model architecture, or submit an issue on github if you think this is'
              ' a bug.'				)

     return model





def  _SCREAMING_SNAKE_CASE		(      *__snake_case							:			Any   ,		**__snake_case							:			Optional[int]				):
     warnings.warn(
         '`replace_8bit_linear` will be deprecated in a future version, please use `replace_with_bnb_linear` instead'   ,		lowerCamelCase_   ,		)
     return replace_with_bnb_linear(*lowerCamelCase_   ,		**lowerCamelCase_				)





def  _SCREAMING_SNAKE_CASE		(      *__snake_case							:			Dict   ,		**__snake_case							:			List[Any]				):
     warnings.warn(
         '`set_module_8bit_tensor_to_device` will be deprecated in a future version, please use `set_module_quantized_tensor_to_device` instead'   ,		lowerCamelCase_   ,		)
     return set_module_quantized_tensor_to_device(*lowerCamelCase_   ,		**lowerCamelCase_				)





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			Optional[int]				):
     _A    		=  deepcopy(lowerCamelCase_				)  # this has 0 cost since it is done inside `init_empty_weights` context manager`
     tied_model.tie_weights()

     _A    		=  find_tied_parameters(lowerCamelCase_				)
     # For compatibility with Accelerate < 0.18
     if isinstance(lowerCamelCase_   ,		lowerCamelCase_				):
          _A    		=  sum(list(tied_params.values()				)   ,		[]				) + list(tied_params.keys()				)
     else:
          _A    		=  sum(lowerCamelCase_   ,		[]				)
     _A    		=  len(lowerCamelCase_				) > 0

     # Check if it is a base model
     _A    		=  not hasattr(lowerCamelCase_   ,		model.base_model_prefix				)

     # Ignore this for base models (BertModel, GPT2Model, etc.)
     if (not has_tied_params) and is_base_model:
          return []

     # otherwise they have an attached head
     _A    		=  list(model.named_children()				)
     _A    		=  [list_modules[-1][0]]

     # add last module together with tied weights
     _A    		=  set(lowerCamelCase_				) - set(lowerCamelCase_				)
     _A    		=  list(set(lowerCamelCase_				)				) + list(lowerCamelCase_				)

     # remove ".weight" from the keys
     _A    		=  [""".weight""", """.bias"""]
     _A    		=  []
     for name in list_untouched:
          for name_to_remove in names_to_remove:
               if name_to_remove in name:
                    _A    		=  name.replace(lowerCamelCase_   ,		''				)
          filtered_module_names.append(lowerCamelCase_				)

     return filtered_module_names










'''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			):




					"""simple docstring"""


					def lowerCamelCase_			(						self				:			Any						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			tempfile.mkdtemp()
							SCREAMING_SNAKE_CASE :				List[Any]		=			SamImageProcessor()
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			SamProcessor(lowerCamelCase_						)
							processor.save_pretrained(self.tmpdirname						)


					def lowerCamelCase_			(						self				:			Dict      ,						**lowerCamelCase_				:			List[str]						):

							'''simple docstring'''



							return AutoProcessor.from_pretrained(self.tmpdirname      ,						**lowerCamelCase_						).image_processor


					def lowerCamelCase_			(						self				:			Dict						):

							'''simple docstring'''



							shutil.rmtree(self.tmpdirname						)


					def lowerCamelCase_			(						self				:			str						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Optional[int]		=			[np.random.randint(2_55      ,						size=(3, 30, 4_00)      ,						dtype=np.uinta						)]

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

							return image_inputs


					def lowerCamelCase_			(						self				:			Any						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				List[Any]		=			SamProcessor(image_processor=self.get_image_processor()						)
							processor.save_pretrained(self.tmpdirname						)

							SCREAMING_SNAKE_CASE :				int		=			self.get_image_processor(do_normalize=lowerCamelCase_      ,						padding_value=1.0						)

							SCREAMING_SNAKE_CASE :				Tuple		=			SamProcessor.from_pretrained(self.tmpdirname      ,						do_normalize=lowerCamelCase_      ,						padding_value=1.0						)

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


					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Optional[Any]		=			self.get_image_processor()

							SCREAMING_SNAKE_CASE :				List[Any]		=			SamProcessor(image_processor=lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Optional[int]		=			self.prepare_image_inputs()

							SCREAMING_SNAKE_CASE :				List[str]		=			image_processor(lowerCamelCase_      ,						return_tensors="""np"""						)
							SCREAMING_SNAKE_CASE :				Dict		=			processor(images=lowerCamelCase_      ,						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 lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				List[str]		=			self.get_image_processor()

							SCREAMING_SNAKE_CASE :				Optional[Any]		=			SamProcessor(image_processor=lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Any		=			[torch.ones((1, 3, 5, 5)						)]

							SCREAMING_SNAKE_CASE :				int		=			[[17_64, 26_46]]

							SCREAMING_SNAKE_CASE :				Any		=			[[6_83, 10_24]]
							SCREAMING_SNAKE_CASE :				str		=			processor.post_process_masks(lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_						)
							self.assertEqual(masks[0].shape      ,						(1, 3, 17_64, 26_46)						)

							SCREAMING_SNAKE_CASE :				str		=			processor.post_process_masks(
							    lowerCamelCase_      ,						torch.tensor(lowerCamelCase_						)      ,						torch.tensor(lowerCamelCase_						)						)
							self.assertEqual(masks[0].shape      ,						(1, 3, 17_64, 26_46)						)

							# should also work with np
							SCREAMING_SNAKE_CASE :				Optional[int]		=			[np.ones((1, 3, 5, 5)						)]
							SCREAMING_SNAKE_CASE :				Optional[int]		=			processor.post_process_masks(lowerCamelCase_      ,						np.array(lowerCamelCase_						)      ,						np.array(lowerCamelCase_						)						)

							self.assertEqual(masks[0].shape      ,						(1, 3, 17_64, 26_46)						)

							SCREAMING_SNAKE_CASE :				Tuple		=			[[1, 0], [0, 1]]
							with self.assertRaises(lowerCamelCase_						):
									SCREAMING_SNAKE_CASE :				Tuple		=			processor.post_process_masks(lowerCamelCase_      ,						np.array(lowerCamelCase_						)      ,						np.array(lowerCamelCase_						)						)







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




					"""simple docstring"""


					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			tempfile.mkdtemp()
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			SamImageProcessor()
							SCREAMING_SNAKE_CASE :				Optional[int]		=			SamProcessor(lowerCamelCase_						)
							processor.save_pretrained(self.tmpdirname						)


					def lowerCamelCase_			(						self				:			Any      ,						**lowerCamelCase_				:			str						):

							'''simple docstring'''



							return AutoProcessor.from_pretrained(self.tmpdirname      ,						**lowerCamelCase_						).image_processor


					def lowerCamelCase_			(						self				:			List[Any]						):

							'''simple docstring'''



							shutil.rmtree(self.tmpdirname						)


					def lowerCamelCase_			(						self				:			Union[str, Any]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Any		=			[np.random.randint(2_55      ,						size=(3, 30, 4_00)      ,						dtype=np.uinta						)]

							SCREAMING_SNAKE_CASE :				str		=			[Image.fromarray(np.moveaxis(lowerCamelCase_      ,						0      ,						-1						)						) for x in image_inputs]

							return image_inputs


					def lowerCamelCase_			(						self				:			List[Any]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			SamProcessor(image_processor=self.get_image_processor()						)
							processor.save_pretrained(self.tmpdirname						)

							SCREAMING_SNAKE_CASE :				Optional[Any]		=			self.get_image_processor(do_normalize=lowerCamelCase_      ,						padding_value=1.0						)

							SCREAMING_SNAKE_CASE :				List[Any]		=			SamProcessor.from_pretrained(self.tmpdirname      ,						do_normalize=lowerCamelCase_      ,						padding_value=1.0						)

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


					def lowerCamelCase_			(						self				:			Optional[Any]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				str		=			self.get_image_processor()

							SCREAMING_SNAKE_CASE :				Dict		=			SamProcessor(image_processor=lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				int		=			self.prepare_image_inputs()

							SCREAMING_SNAKE_CASE :				Optional[Any]		=			image_processor(lowerCamelCase_      ,						return_tensors="""np"""						)
							SCREAMING_SNAKE_CASE :				List[Any]		=			processor(images=lowerCamelCase_      ,						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 lowerCamelCase_			(						self				:			Dict						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Dict		=			self.get_image_processor()

							SCREAMING_SNAKE_CASE :				Tuple		=			SamProcessor(image_processor=lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			[tf.ones((1, 3, 5, 5)						)]

							SCREAMING_SNAKE_CASE :				Dict		=			[[17_64, 26_46]]

							SCREAMING_SNAKE_CASE :				Any		=			[[6_83, 10_24]]
							SCREAMING_SNAKE_CASE :				str		=			processor.post_process_masks(lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_      ,						return_tensors="""tf"""						)
							self.assertEqual(masks[0].shape      ,						(1, 3, 17_64, 26_46)						)

							SCREAMING_SNAKE_CASE :				Optional[int]		=			processor.post_process_masks(
							    lowerCamelCase_      ,						tf.convert_to_tensor(lowerCamelCase_						)      ,						tf.convert_to_tensor(lowerCamelCase_						)      ,						return_tensors="""tf"""      ,						)
							self.assertEqual(masks[0].shape      ,						(1, 3, 17_64, 26_46)						)

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

							self.assertEqual(masks[0].shape      ,						(1, 3, 17_64, 26_46)						)

							SCREAMING_SNAKE_CASE :				str		=			[[1, 0], [0, 1]]
							with self.assertRaises(tf.errors.InvalidArgumentError						):
									SCREAMING_SNAKE_CASE :				Tuple		=			processor.post_process_masks(
									    lowerCamelCase_      ,						np.array(lowerCamelCase_						)      ,						np.array(lowerCamelCase_						)      ,						return_tensors="""tf"""						)







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




					"""simple docstring"""


					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				int		=			tempfile.mkdtemp()
							SCREAMING_SNAKE_CASE :				int		=			SamImageProcessor()
							SCREAMING_SNAKE_CASE :				str		=			SamProcessor(lowerCamelCase_						)
							processor.save_pretrained(self.tmpdirname						)


					def lowerCamelCase_			(						self				:			Tuple      ,						**lowerCamelCase_				:			List[Any]						):

							'''simple docstring'''



							return AutoProcessor.from_pretrained(self.tmpdirname      ,						**lowerCamelCase_						).image_processor


					def lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							shutil.rmtree(self.tmpdirname						)


					def lowerCamelCase_			(						self				:			Dict						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Optional[int]		=			[np.random.randint(2_55      ,						size=(3, 30, 4_00)      ,						dtype=np.uinta						)]

							SCREAMING_SNAKE_CASE :				Dict		=			[Image.fromarray(np.moveaxis(lowerCamelCase_      ,						0      ,						-1						)						) for x in image_inputs]

							return image_inputs


					@is_pt_tf_cross_test
					def lowerCamelCase_			(						self				:			Optional[Any]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				str		=			self.get_image_processor()

							SCREAMING_SNAKE_CASE :				Dict		=			SamProcessor(image_processor=lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Any		=			np.random.randint(0      ,						2      ,						size=(1, 3, 5, 5)						).astype(np.floataa						)
							SCREAMING_SNAKE_CASE :				str		=			[tf.convert_to_tensor(lowerCamelCase_						)]
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			[torch.tensor(lowerCamelCase_						)]

							SCREAMING_SNAKE_CASE :				Tuple		=			[[17_64, 26_46]]

							SCREAMING_SNAKE_CASE :				Optional[Any]		=			[[6_83, 10_24]]
							SCREAMING_SNAKE_CASE :				Tuple		=			processor.post_process_masks(
							    lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_      ,						return_tensors="""tf"""						)
							SCREAMING_SNAKE_CASE :				Any		=			processor.post_process_masks(
							    lowerCamelCase_      ,						lowerCamelCase_      ,						lowerCamelCase_      ,						return_tensors="""pt"""						)

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



					@is_pt_tf_cross_test
					def lowerCamelCase_			(						self				:			Tuple						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			self.get_image_processor()

							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			SamProcessor(image_processor=lowerCamelCase_						)

							SCREAMING_SNAKE_CASE :				Any		=			self.prepare_image_inputs()

							SCREAMING_SNAKE_CASE :				int		=			image_processor(lowerCamelCase_      ,						return_tensors="""pt"""						)["""pixel_values"""].numpy()
							SCREAMING_SNAKE_CASE :				Tuple		=			processor(images=lowerCamelCase_      ,						return_tensors="""pt"""						)["""pixel_values"""].numpy()

							SCREAMING_SNAKE_CASE :				Dict		=			image_processor(lowerCamelCase_      ,						return_tensors="""tf"""						)["""pixel_values"""].numpy()
							SCREAMING_SNAKE_CASE :				Dict		=			processor(images=lowerCamelCase_      ,						return_tensors="""tf"""						)["""pixel_values"""].numpy()

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



