


from __future__ import annotations

import collections
import tempfile
import unittest

import numpy as np

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

from ...test_modeling_tf_common import floats_tensor, ids_tensor, random_attention_mask
from ..bert.test_modeling_tf_bert import TFBertModelTester
from ..clip.test_modeling_tf_clip import TFCLIPVisionModelTester
from ..deit.test_modeling_tf_deit import TFDeiTModelTester
from ..roberta.test_modeling_tf_roberta import TFRobertaModelTester
from ..vit.test_modeling_tf_vit import TFViTModelTester


if is_tf_available():
   from transformers import (
       TFBertModel,
       TFCLIPVisionModel,
       TFDeiTModel,
       TFRobertaModel,
       TFVisionTextDualEncoderModel,
       TFViTModel,
       VisionTextDualEncoderConfig,
   )

if is_vision_available():
   from PIL import Image

   from transformers import VisionTextDualEncoderProcessor






def 		lowercase_(  SCREAMING_SNAKE_CASE_	):


  '''simple docstring'''

  if isinstance(SCREAMING_SNAKE_CASE_      ,						collections.abc.Iterable	):
    return x
  return (x, x)
@require_tf
class 	UpperCAmelCase_					:

   '''simple docstring'''




   def _snake_case    (		self						,				__A						,				__A ):






     """simple docstring"""





     pass






   def _snake_case    (		self ):






     """simple docstring"""





     pass






   def _snake_case    (		self ):






     """simple docstring"""





     pass






   def _snake_case    (		self						,				__A						,				__A						,				__A						,				__A						,				__A=None						,				**__A ):






     """simple docstring"""





     lowerCamelCase :					Tuple    =				VisionTextDualEncoderConfig.from_vision_text_configs(__lowerCamelCase						,				__lowerCamelCase )

     lowerCamelCase :					Dict    =				TFVisionTextDualEncoderModel(__lowerCamelCase )

     lowerCamelCase :					str    =				model(input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase )

     self.assertEqual(output["text_embeds"].shape						,				(input_ids.shape[0], config.projection_dim) )
     self.assertEqual(output["image_embeds"].shape						,				(pixel_values.shape[0], config.projection_dim) )






   def _snake_case    (		self						,				__A						,				__A						,				__A						,				__A						,				__A=None						,				**__A ):






     """simple docstring"""





     lowerCamelCase    ,	lowerCamelCase :					Optional[Any]    =				self.get_vision_text_model(__lowerCamelCase						,				__lowerCamelCase )
     lowerCamelCase :					Optional[int]    =				TFVisionTextDualEncoderModel(vision_model=__lowerCamelCase						,				text_model=__lowerCamelCase )

     lowerCamelCase :					Any    =				model(input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase )

     self.assertEqual(output["text_embeds"].shape						,				(input_ids.shape[0], model.config.projection_dim) )
     self.assertEqual(output["image_embeds"].shape						,				(pixel_values.shape[0], model.config.projection_dim) )






   def _snake_case    (		self						,				__A						,				__A						,				__A						,				__A						,				__A=None						,				**__A ):






     """simple docstring"""





     lowerCamelCase    ,	lowerCamelCase :					Dict    =				self.get_vision_text_model(__lowerCamelCase						,				__lowerCamelCase )
     lowerCamelCase :					Tuple    =				{"vision_model": vision_model, "text_model": text_model}
     lowerCamelCase :					Tuple    =				TFVisionTextDualEncoderModel.from_vision_text_pretrained(**__lowerCamelCase )

     lowerCamelCase :					Dict    =				model(input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase )

     self.assertEqual(output["text_embeds"].shape						,				(input_ids.shape[0], model.config.projection_dim) )
     self.assertEqual(output["image_embeds"].shape						,				(pixel_values.shape[0], model.config.projection_dim) )






   def _snake_case    (		self						,				__A						,				__A						,				__A						,				__A						,				__A=None						,				**__A ):






     """simple docstring"""





     lowerCamelCase    ,	lowerCamelCase :					Tuple    =				self.get_vision_text_model(__lowerCamelCase						,				__lowerCamelCase )
     lowerCamelCase :					List[str]    =				TFVisionTextDualEncoderModel(vision_model=__lowerCamelCase						,				text_model=__lowerCamelCase )

     lowerCamelCase :					List[Any]    =				model(input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase )
     lowerCamelCase :					List[Any]    =				output[0].numpy()

     with tempfile.TemporaryDirectory() as tmpdirname:
       model.save_pretrained(__lowerCamelCase )
       lowerCamelCase :					Tuple    =				TFVisionTextDualEncoderModel.from_pretrained(__lowerCamelCase )

       lowerCamelCase :					List[Any]    =				model(input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase )
       lowerCamelCase :					str    =				after_output[0].numpy()
       lowerCamelCase :					Optional[Any]    =				np.amax(np.abs(out_a - out_a ) )
       self.assertLessEqual(__lowerCamelCase						,				1e-5 )






   def _snake_case    (		self						,				__A						,				__A						,				__A						,				__A						,				__A=None						,				**__A ):






     """simple docstring"""





     lowerCamelCase    ,	lowerCamelCase :					str    =				self.get_vision_text_model(__lowerCamelCase						,				__lowerCamelCase )
     lowerCamelCase :					Union[str, Any]    =				TFVisionTextDualEncoderModel(vision_model=__lowerCamelCase						,				text_model=__lowerCamelCase )

     lowerCamelCase :					List[Any]    =				model(
         input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase						,				output_attentions=__lowerCamelCase )

     lowerCamelCase :					List[Any]    =				output.vision_model_output.attentions
     self.assertEqual(len(__lowerCamelCase )						,				vision_config.num_hidden_layers )

     # in ViT, the seq_len equals the number of patches + 1 (we add 1 for the [CLS] token)
     lowerCamelCase :					str    =				to_atuple(vision_model.config.image_size )
     lowerCamelCase :					List[Any]    =				to_atuple(vision_model.config.patch_size )
     lowerCamelCase :					List[str]    =				(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
     lowerCamelCase :					Any    =				num_patches + 1
     self.assertEqual(vision_attentions[0].shape[-3:]						,				(vision_config.num_attention_heads, seq_len, seq_len) )

     lowerCamelCase :					Dict    =				output.text_model_output.attentions
     self.assertEqual(len(__lowerCamelCase )						,				text_config.num_hidden_layers )

     self.assertEqual(
         text_attentions[0].shape[-3:]						,				(text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1])						,				)






   def _snake_case    (		self						,				__A						,				__A						,				__A ):






     """simple docstring"""





     lowerCamelCase :					Optional[int]    =				np.abs((a - b) ).max()
     self.assertLessEqual(__lowerCamelCase						,				__lowerCamelCase						,				F"""Difference between torch and flax is {diff} (>= {tol}).""" )






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					List[Any]    =				self.prepare_config_and_inputs()
     self.check_vision_text_dual_encoder_model(**__lowerCamelCase )






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Optional[int]    =				self.prepare_config_and_inputs()
     self.check_model_from_pretrained_configs(**__lowerCamelCase )






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					List[Any]    =				self.prepare_config_and_inputs()
     self.check_vision_text_dual_encoder_from_pretrained(**__lowerCamelCase )






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Union[str, Any]    =				self.prepare_config_and_inputs()
     self.check_save_load(**__lowerCamelCase )






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Optional[int]    =				self.prepare_config_and_inputs()
     self.check_vision_text_output_attention(**__lowerCamelCase )






   @slow
   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase    ,	lowerCamelCase :					Optional[int]    =				self.get_pretrained_model_and_inputs()

     lowerCamelCase :					Union[str, Any]    =				model_a(**__lowerCamelCase )
     lowerCamelCase :					str    =				outputs[0].numpy()

     with tempfile.TemporaryDirectory() as tmp_dirname:
       model_a.save_pretrained(__lowerCamelCase )
       lowerCamelCase :					Optional[int]    =				TFVisionTextDualEncoderModel.from_pretrained(__lowerCamelCase )

       lowerCamelCase :					Tuple    =				model_a(**__lowerCamelCase )
       lowerCamelCase :					List[str]    =				after_outputs[0].numpy()
       lowerCamelCase :					Optional[int]    =				np.amax(np.abs(out_a - out_a ) )
       self.assertLessEqual(__lowerCamelCase						,				1e-5 )



@require_tf
class 	UpperCAmelCase_					(					_UpperCamelCase		, unittest.TestCase    ):

   '''simple docstring'''




   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					int    =				TFVisionTextDualEncoderModel.from_vision_text_pretrained(
         "hf-internal-testing/tiny-random-vit"						,				"hf-internal-testing/tiny-random-bert" )
     lowerCamelCase :					Tuple    =				13
     lowerCamelCase :					Optional[Any]    =				floats_tensor(
         [
             batch_size,
             model.vision_model.config.num_channels,
             model.vision_model.config.image_size,
             model.vision_model.config.image_size,
         ] )
     lowerCamelCase :					int    =				ids_tensor([batch_size, 4]						,				model.text_model.config.vocab_size )
     lowerCamelCase :					Dict    =				random_attention_mask([batch_size, 4] )
     lowerCamelCase :					Optional[Any]    =				{"pixel_values": pixel_values, "input_ids": input_ids, "attention_mask": attention_mask}

     return model, inputs






   def _snake_case    (		self						,				__A						,				__A ):






     """simple docstring"""





     lowerCamelCase :					Any    =				TFViTModel(__lowerCamelCase						,				name="vision_model" )
     lowerCamelCase :					Dict    =				TFBertModel(__lowerCamelCase						,				name="text_model" )
     return vision_model, text_model






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Optional[int]    =				TFViTModelTester(self )
     lowerCamelCase :					Tuple    =				TFBertModelTester(self )
     lowerCamelCase :					str    =				vit_model_tester.prepare_config_and_inputs()
     lowerCamelCase :					Any    =				bert_model_tester.prepare_config_and_inputs()

     lowerCamelCase    ,	lowerCamelCase    ,	lowerCamelCase :					str    =				vision_config_and_inputs

     (
         (
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,			
     ) :					Tuple    =				text_config_and_inputs

     return {
         "text_config": text_config,
         "vision_config": vision_config,
         "pixel_values": pixel_values,
         "attention_mask": input_mask,
         "input_ids": input_ids,
         "text_token_type_ids": token_type_ids,
         "text_sequence_labels": sequence_labels,
         "text_token_labels": token_labels,
         "text_choice_labels": choice_labels,
     }



@require_tf
class 	UpperCAmelCase_					(					_UpperCamelCase		, unittest.TestCase    ):

   '''simple docstring'''




   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Optional[Any]    =				TFVisionTextDualEncoderModel.from_vision_text_pretrained(
         "Rocketknight1/tiny-random-deit-tf"						,				"hf-internal-testing/tiny-random-roberta" )
     lowerCamelCase :					Optional[Any]    =				13
     lowerCamelCase :					str    =				floats_tensor(
         [
             batch_size,
             model.vision_model.config.num_channels,
             model.vision_model.config.image_size,
             model.vision_model.config.image_size,
         ] )
     lowerCamelCase :					List[str]    =				ids_tensor([batch_size, 4]						,				model.text_model.config.vocab_size )
     lowerCamelCase :					Union[str, Any]    =				random_attention_mask([batch_size, 4] )
     lowerCamelCase :					List[str]    =				{"pixel_values": pixel_values, "input_ids": input_ids, "attention_mask": attention_mask}

     return model, inputs






   def _snake_case    (		self						,				__A						,				__A						,				__A						,				__A						,				__A=None						,				**__A ):






     """simple docstring"""





     lowerCamelCase    ,	lowerCamelCase :					int    =				self.get_vision_text_model(__lowerCamelCase						,				__lowerCamelCase )
     lowerCamelCase :					List[str]    =				TFVisionTextDualEncoderModel(vision_model=__lowerCamelCase						,				text_model=__lowerCamelCase )

     lowerCamelCase :					List[Any]    =				model(
         input_ids=__lowerCamelCase						,				pixel_values=__lowerCamelCase						,				attention_mask=__lowerCamelCase						,				output_attentions=__lowerCamelCase )

     lowerCamelCase :					Tuple    =				output.vision_model_output.attentions
     self.assertEqual(len(__lowerCamelCase )						,				vision_config.num_hidden_layers )

     # in DEiT, the seq_len equals the number of patches + 2 (we add 2 for the [CLS] and distillation tokens)
     lowerCamelCase :					Tuple    =				to_atuple(vision_model.config.image_size )
     lowerCamelCase :					Optional[Any]    =				to_atuple(vision_model.config.patch_size )
     lowerCamelCase :					Union[str, Any]    =				(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
     lowerCamelCase :					List[Any]    =				num_patches + 2
     self.assertEqual(vision_attentions[0].shape[-3:]						,				(vision_config.num_attention_heads, seq_len, seq_len) )

     lowerCamelCase :					int    =				output.text_model_output.attentions
     self.assertEqual(len(__lowerCamelCase )						,				text_config.num_hidden_layers )

     self.assertEqual(
         text_attentions[0].shape[-3:]						,				(text_config.num_attention_heads, input_ids.shape[-1], input_ids.shape[-1])						,				)






   def _snake_case    (		self						,				__A						,				__A ):






     """simple docstring"""





     lowerCamelCase :					Optional[int]    =				TFDeiTModel(__lowerCamelCase						,				name="vision_model" )
     lowerCamelCase :					Optional[int]    =				TFRobertaModel(__lowerCamelCase						,				name="text_model" )
     return vision_model, text_model






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Any    =				TFDeiTModelTester(self )
     lowerCamelCase :					Tuple    =				TFRobertaModelTester(self )
     lowerCamelCase :					List[Any]    =				vit_model_tester.prepare_config_and_inputs()
     lowerCamelCase :					List[str]    =				bert_model_tester.prepare_config_and_inputs()

     lowerCamelCase    ,	lowerCamelCase    ,	lowerCamelCase :					Union[str, Any]    =				vision_config_and_inputs

     (
         (
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,			
     ) :					Union[str, Any]    =				text_config_and_inputs

     return {
         "text_config": text_config,
         "vision_config": vision_config,
         "pixel_values": pixel_values,
         "attention_mask": input_mask,
         "input_ids": input_ids,
         "text_token_type_ids": token_type_ids,
         "text_sequence_labels": sequence_labels,
         "text_token_labels": token_labels,
         "text_choice_labels": choice_labels,
     }



@require_tf
class 	UpperCAmelCase_					(					_UpperCamelCase		, unittest.TestCase    ):

   '''simple docstring'''




   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Optional[Any]    =				TFVisionTextDualEncoderModel.from_vision_text_pretrained(
         "Rocketknight1/tiny-random-clip-tf"						,				"hf-internal-testing/tiny-random-bert" )
     lowerCamelCase :					Any    =				13
     lowerCamelCase :					int    =				floats_tensor(
         [
             batch_size,
             model.vision_model.config.num_channels,
             model.vision_model.config.image_size,
             model.vision_model.config.image_size,
         ] )
     lowerCamelCase :					int    =				ids_tensor([batch_size, 4]						,				model.text_model.config.vocab_size )
     lowerCamelCase :					int    =				random_attention_mask([batch_size, 4] )
     lowerCamelCase :					str    =				{"pixel_values": pixel_values, "input_ids": input_ids, "attention_mask": attention_mask}

     return model, inputs






   def _snake_case    (		self						,				__A						,				__A ):






     """simple docstring"""





     lowerCamelCase :					Optional[Any]    =				TFCLIPVisionModel(__lowerCamelCase						,				name="vision_model" )
     lowerCamelCase :					List[str]    =				TFBertModel(__lowerCamelCase						,				name="text_model" )
     return vision_model, text_model






   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Union[str, Any]    =				TFCLIPVisionModelTester(self )
     lowerCamelCase :					List[str]    =				TFBertModelTester(self )
     lowerCamelCase :					Any    =				clip_model_tester.prepare_config_and_inputs()
     lowerCamelCase :					List[Any]    =				bert_model_tester.prepare_config_and_inputs()

     lowerCamelCase    ,	lowerCamelCase :					str    =				vision_config_and_inputs

     (
         (
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,	(
         lowerCamelCase		
     )    ,			
     ) :					Tuple    =				text_config_and_inputs

     return {
         "text_config": text_config,
         "vision_config": vision_config,
         "pixel_values": pixel_values,
         "attention_mask": input_mask,
         "input_ids": input_ids,
         "text_token_type_ids": token_type_ids,
         "text_sequence_labels": sequence_labels,
         "text_token_labels": token_labels,
         "text_choice_labels": choice_labels,
     }



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

   '''simple docstring'''




   @slow
   def _snake_case    (		self ):






     """simple docstring"""





     lowerCamelCase :					Optional[int]    =				TFVisionTextDualEncoderModel.from_pretrained(
         "clip-italian/clip-italian"						,				logit_scale_init_value=1.0						,				from_pt=__lowerCamelCase )
     lowerCamelCase :					Union[str, Any]    =				VisionTextDualEncoderProcessor.from_pretrained("clip-italian/clip-italian" )

     lowerCamelCase :					int    =				Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png" )
     lowerCamelCase :					Optional[Any]    =				processor(
         text=["una foto di un gatto", "una foto di un cane"]						,				images=__lowerCamelCase						,				padding=__lowerCamelCase						,				return_tensors="np" )

     lowerCamelCase :					Dict    =				model(**__lowerCamelCase )

     # verify the logits
     self.assertEqual(outputs.logits_per_image.shape						,				(inputs.pixel_values.shape[0], inputs.input_ids.shape[0]) )
     self.assertEqual(
         outputs.logits_per_text.shape						,				(inputs.input_ids.shape[0], inputs.pixel_values.shape[0])						,				)

     lowerCamelCase :					List[Any]    =				np.array([[1.2284727, 0.3104122]] )

     self.assertTrue(np.allclose(outputs.logits_per_image.numpy()						,				__lowerCamelCase						,				atol=1e-3 ) )









# Lint as: python3
import sys
from collections.abc import Mapping
from typing import TYPE_CHECKING

import numpy as np
import pyarrow as pa

from .. import config
from ..utils.py_utils import map_nested
from .formatting import TensorFormatter


if TYPE_CHECKING:
		import torch




class     snake_case__							(TensorFormatter[Mapping, """torch.Tensor""", Mapping]   ):
				"""simple docstring"""



				def __init__(      self				:     Tuple					,      __lowerCamelCase				:     Union[str, Any]=None					,      **__lowerCamelCase				:     Any							)					->     Optional[Any]:
							super().__init__(features=__lowerCamelCase							)
							a    =			torch_tensor_kwargs
							import torch  # noqa import torch at initialization





				def 							__UpperCAmelCase							(      self				:     List[str]					,      __lowerCamelCase				:     Dict							)					->     Dict:
							import torch

							if isinstance(__lowerCamelCase					,      __lowerCamelCase							) and column:
										if all(
										    isinstance(__lowerCamelCase					,      torch.Tensor							) and x.shape == column[0].shape and x.dtype == column[0].dtype
										    for x in column							):
													return torch.stack(__lowerCamelCase							)
							return column





				def 							__UpperCAmelCase							(      self				:     Optional[Any]					,      __lowerCamelCase				:     List[Any]							)					->     str:
							import torch

							if isinstance(__lowerCamelCase					,      (str, bytes, type(__lowerCamelCase							))							):
										return value
							elif isinstance(__lowerCamelCase					,      (np.character, np.ndarray)							) and np.issubdtype(value.dtype					,      np.character							):
										return value.tolist()

							a    =			{}

							if isinstance(__lowerCamelCase					,      (np.number, np.ndarray)							) and np.issubdtype(value.dtype					,      np.integer							):
										a    =			{"dtype": torch.intaa}
							elif isinstance(__lowerCamelCase					,      (np.number, np.ndarray)							) and np.issubdtype(value.dtype					,      np.floating							):
										a    =			{"dtype": torch.floataa}
							elif config.PIL_AVAILABLE and "PIL" in sys.modules:
										import PIL.Image

										if isinstance(__lowerCamelCase					,      PIL.Image.Image							):
													a    =			np.asarray(__lowerCamelCase							)
							return torch.tensor(__lowerCamelCase					,      **{**default_dtype, **self.torch_tensor_kwargs}							)





				def 							__UpperCAmelCase							(      self				:     List[str]					,      __lowerCamelCase				:     Tuple							)					->     List[str]:
							import torch

							# support for torch, tf, jax etc.
							if hasattr(__lowerCamelCase					,      "__array__"							) and not isinstance(__lowerCamelCase					,      torch.Tensor							):
										a    =			data_struct.__array__()
							# support for nested types like struct of list of struct
							if isinstance(__lowerCamelCase					,      np.ndarray							):
										if data_struct.dtype == object:  # torch tensors cannot be instantied from an array of objects
													return self._consolidate([self.recursive_tensorize(__lowerCamelCase							) for substruct in data_struct]							)
							elif isinstance(__lowerCamelCase					,      (list, tuple)							):
										return self._consolidate([self.recursive_tensorize(__lowerCamelCase							) for substruct in data_struct]							)
							return self._tensorize(__lowerCamelCase							)





				def 							__UpperCAmelCase							(      self				:     int					,      __lowerCamelCase				:     dict							)					->     str:
							return map_nested(self._recursive_tensorize					,      __lowerCamelCase					,      map_list=__lowerCamelCase							)





				def 							__UpperCAmelCase							(      self				:     Optional[Any]					,      __lowerCamelCase				:     pa.Table							)					->     Mapping:
							a    =			self.numpy_arrow_extractor().extract_row(__lowerCamelCase							)
							a    =			self.python_features_decoder.decode_row(__lowerCamelCase							)
							return self.recursive_tensorize(__lowerCamelCase							)





				def 							__UpperCAmelCase							(      self				:     int					,      __lowerCamelCase				:     pa.Table							)					->     "torch.Tensor":
							a    =			self.numpy_arrow_extractor().extract_column(__lowerCamelCase							)
							a    =			self.python_features_decoder.decode_column(__lowerCamelCase					,      pa_table.column_names[0]							)
							a    =			self.recursive_tensorize(__lowerCamelCase							)
							a    =			self._consolidate(__lowerCamelCase							)
							return column





				def 							__UpperCAmelCase							(      self				:     Optional[Any]					,      __lowerCamelCase				:     pa.Table							)					->     Mapping:
							a    =			self.numpy_arrow_extractor().extract_batch(__lowerCamelCase							)
							a    =			self.python_features_decoder.decode_batch(__lowerCamelCase							)
							a    =			self.recursive_tensorize(__lowerCamelCase							)
							for column_name in batch:
										a    =			self._consolidate(batch[column_name]							)
							return batch






