

import json
import pathlib
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision, slow
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
			import torch

if is_vision_available():
			from PIL import Image

			from transformers import DeformableDetrImageProcessor






class _UpperCamelCase				(				unittest.TestCase ):
			'''simple docstring'''







			def __init__(      self				:			Optional[int]   ,   a				:			List[str]   ,   a				:			Optional[int]=7   ,   a				:			Tuple=3   ,   a				:			Optional[Any]=30   ,   a				:			Optional[Any]=400   ,   a				:			Optional[Any]=True   ,   a				:			List[str]=None   ,   a				:			Optional[Any]=True   ,   a				:			Union[str, Any]=[0.5, 0.5, 0.5]   ,   a				:			Optional[int]=[0.5, 0.5, 0.5]   ,   a				:			Optional[Any]=True   ,   a				:			Dict=1 / 255   ,   a				:			Dict=True   ,   )				->							Tuple:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Any					  =							size if size is not None else {"shortest_edge": 18, "longest_edge": 1333}
				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							parent
				SCREAMING_SNAKE_CASE :   str					  =							batch_size
				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							num_channels
				SCREAMING_SNAKE_CASE :   Any					  =							min_resolution
				SCREAMING_SNAKE_CASE :   List[Any]					  =							max_resolution
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							do_resize
				SCREAMING_SNAKE_CASE :   Any					  =							size
				SCREAMING_SNAKE_CASE :   int					  =							do_normalize
				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							image_mean
				SCREAMING_SNAKE_CASE :   Dict					  =							image_std
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							do_rescale
				SCREAMING_SNAKE_CASE :   str					  =							rescale_factor
				SCREAMING_SNAKE_CASE :   Any					  =							do_pad
			def 				__UpperCamelCase			(      self				:			Any						)				->							List[Any]:

				"""simple docstring"""

				return {
				    "do_resize": self.do_resize,
				    "size": self.size,
				    "do_normalize": self.do_normalize,
				    "image_mean": self.image_mean,
				    "image_std": self.image_std,
				    "do_rescale": self.do_rescale,
				    "rescale_factor": self.rescale_factor,
				    "do_pad": self.do_pad,
				}






			def 				__UpperCamelCase			(      self				:			List[Any]   ,   a				:			List[Any]   ,   a				:			str=False						)				->							Tuple:

				"""simple docstring"""

				if not batched:
					SCREAMING_SNAKE_CASE :   Any					  =							image_inputs[0]
					if isinstance(a   ,   Image.Image						):
						SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   List[str]					  =							image.size
					else:
						SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   int					  =							image.shape[1], image.shape[2]
					if w < h:
						SCREAMING_SNAKE_CASE :   List[Any]					  =							int(self.size["shortest_edge"] * h / w						)
						SCREAMING_SNAKE_CASE :   List[Any]					  =							self.size["shortest_edge"]
					elif w > h:
						SCREAMING_SNAKE_CASE :   Optional[int]					  =							self.size["shortest_edge"]
						SCREAMING_SNAKE_CASE :   List[Any]					  =							int(self.size["shortest_edge"] * w / h						)
					else:
						SCREAMING_SNAKE_CASE :   Tuple					  =							self.size["shortest_edge"]
						SCREAMING_SNAKE_CASE :   Optional[int]					  =							self.size["shortest_edge"]

				else:
					SCREAMING_SNAKE_CASE :   Any					  =							[]
					for image in image_inputs:
						SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							self.get_expected_values([image]						)
						expected_values.append((expected_height, expected_width)						)
					SCREAMING_SNAKE_CASE :   Optional[int]					  =							max(a   ,   key=lambda a						: item[0]						)[0]
					SCREAMING_SNAKE_CASE :   str					  =							max(a   ,   key=lambda a						: item[1]						)[1]

				return expected_height, expected_width






@require_torch
@require_vision
class _UpperCamelCase				(				__A				,						unittest.TestCase ):
			'''simple docstring'''







			lowerCamelCase__							     =DeformableDetrImageProcessor if is_vision_available() else None
			def 				__UpperCamelCase			(      self				:			List[Any]						)				->							str:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Dict					  =							DeformableDetrImageProcessingTester(self						)
			@property
			def 				__UpperCamelCase			(      self				:			Optional[Any]						)				->							Any:

				"""simple docstring"""

				return self.image_processor_tester.prepare_image_processor_dict()
			def 				__UpperCamelCase			(      self				:			List[str]						)				->							List[str]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   List[Any]					  =							self.image_processing_class(**self.image_processor_dict						)
				self.assertTrue(hasattr(a   ,   "image_mean"						)						)
				self.assertTrue(hasattr(a   ,   "image_std"						)						)
				self.assertTrue(hasattr(a   ,   "do_normalize"						)						)
				self.assertTrue(hasattr(a   ,   "do_resize"						)						)
				self.assertTrue(hasattr(a   ,   "do_rescale"						)						)
				self.assertTrue(hasattr(a   ,   "do_pad"						)						)
				self.assertTrue(hasattr(a   ,   "size"						)						)
			def 				__UpperCamelCase			(      self				:			Dict						)				->							Tuple:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self.image_processing_class.from_dict(self.image_processor_dict						)
				self.assertEqual(image_processor.size   ,   {"shortest_edge": 18, "longest_edge": 1333}						)
				self.assertEqual(image_processor.do_pad   ,   a						)

				SCREAMING_SNAKE_CASE :   Dict					  =							self.image_processing_class.from_dict(
				    self.image_processor_dict   ,   size=42   ,   max_size=84   ,   pad_and_return_pixel_mask=a						)
				self.assertEqual(image_processor.size   ,   {"shortest_edge": 42, "longest_edge": 84}						)
				self.assertEqual(image_processor.do_pad   ,   a						)
			def 				__UpperCamelCase			(      self				:			Union[str, Any]						)				->							int:

				"""simple docstring"""

				pass
			def 				__UpperCamelCase			(      self				:			Dict						)				->							Tuple:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Any					  =							self.image_processing_class(**self.image_processor_dict						)
				# create random PIL images
				SCREAMING_SNAKE_CASE :   List[str]					  =							prepare_image_inputs(self.image_processor_tester   ,   equal_resolution=a						)
				for image in image_inputs:
					self.assertIsInstance(a   ,   Image.Image						)

				# Test not batched input
				SCREAMING_SNAKE_CASE :   List[str]					  =							image_processing(image_inputs[0]   ,   return_tensors="pt"						).pixel_values

				SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   int					  =							self.image_processor_tester.get_expected_values(a						)

				self.assertEqual(
				    encoded_images.shape   ,   (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,   )

				# Test batched
				SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							self.image_processor_tester.get_expected_values(a   ,   batched=a						)

				SCREAMING_SNAKE_CASE :   int					  =							image_processing(a   ,   return_tensors="pt"						).pixel_values
				self.assertEqual(
				    encoded_images.shape   ,   (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        expected_height,
				        expected_width,
				    )   ,   )
			def 				__UpperCamelCase			(      self				:			str						)				->							List[Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   List[str]					  =							self.image_processing_class(**self.image_processor_dict						)
				# create random numpy tensors
				SCREAMING_SNAKE_CASE :   List[Any]					  =							prepare_image_inputs(self.image_processor_tester   ,   equal_resolution=a   ,   numpify=a						)
				for image in image_inputs:
					self.assertIsInstance(a   ,   np.ndarray						)

				# Test not batched input
				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							image_processing(image_inputs[0]   ,   return_tensors="pt"						).pixel_values

				SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   Optional[int]					  =							self.image_processor_tester.get_expected_values(a						)

				self.assertEqual(
				    encoded_images.shape   ,   (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,   )

				# Test batched
				SCREAMING_SNAKE_CASE :   List[str]					  =							image_processing(a   ,   return_tensors="pt"						).pixel_values

				SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   List[str]					  =							self.image_processor_tester.get_expected_values(a   ,   batched=a						)

				self.assertEqual(
				    encoded_images.shape   ,   (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        expected_height,
				        expected_width,
				    )   ,   )
			def 				__UpperCamelCase			(      self				:			List[str]						)				->							str:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   List[str]					  =							self.image_processing_class(**self.image_processor_dict						)
				# create random PyTorch tensors
				SCREAMING_SNAKE_CASE :   Any					  =							prepare_image_inputs(self.image_processor_tester   ,   equal_resolution=a   ,   torchify=a						)
				for image in image_inputs:
					self.assertIsInstance(a   ,   torch.Tensor						)

				# Test not batched input
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							image_processing(image_inputs[0]   ,   return_tensors="pt"						).pixel_values

				SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   List[Any]					  =							self.image_processor_tester.get_expected_values(a						)

				self.assertEqual(
				    encoded_images.shape   ,   (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,   )

				# Test batched
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							image_processing(a   ,   return_tensors="pt"						).pixel_values

				SCREAMING_SNAKE_CASE  ,SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							self.image_processor_tester.get_expected_values(a   ,   batched=a						)

				self.assertEqual(
				    encoded_images.shape   ,   (
				        self.image_processor_tester.batch_size,
				        self.image_processor_tester.num_channels,
				        expected_height,
				        expected_width,
				    )   ,   )
			@slow
			def 				__UpperCamelCase			(      self				:			Optional[int]						)				->							Union[str, Any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   List[Any]					  =							Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						)
				with open("./tests/fixtures/tests_samples/COCO/coco_annotations.txt"   ,   "r"						) as f:
					SCREAMING_SNAKE_CASE :   Optional[int]					  =							json.loads(f.read()						)

				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							{"image_id": 3_9769, "annotations": target}

				# encode them
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							DeformableDetrImageProcessor()
				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							image_processing(images=a   ,   annotations=a   ,   return_tensors="pt"						)

				# verify pixel values
				SCREAMING_SNAKE_CASE :   List[Any]					  =							torch.Size([1, 3, 800, 1066]						)
				self.assertEqual(encoding["pixel_values"].shape   ,   a						)

				SCREAMING_SNAKE_CASE :   int					  =							torch.tensor([0.2796, 0.3138, 0.3481]						)
				self.assertTrue(torch.allclose(encoding["pixel_values"][0, 0, 0, :3]   ,   a   ,   atol=1e-4						)						)

				# verify area
				SCREAMING_SNAKE_CASE :   str					  =							torch.tensor([5887.9600, 1_1250.2061, 48_9353.8438, 83_7122.7500, 14_7967.5156, 16_5732.3438]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["area"]   ,   a						)						)
				# verify boxes
				SCREAMING_SNAKE_CASE :   int					  =							torch.Size([6, 4]						)
				self.assertEqual(encoding["labels"][0]["boxes"].shape   ,   a						)
				SCREAMING_SNAKE_CASE :   List[str]					  =							torch.tensor([0.5503, 0.2765, 0.0604, 0.2215]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["boxes"][0]   ,   a   ,   atol=1e-3						)						)
				# verify image_id
				SCREAMING_SNAKE_CASE :   Dict					  =							torch.tensor([3_9769]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["image_id"]   ,   a						)						)
				# verify is_crowd
				SCREAMING_SNAKE_CASE :   str					  =							torch.tensor([0, 0, 0, 0, 0, 0]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["iscrowd"]   ,   a						)						)
				# verify class_labels
				SCREAMING_SNAKE_CASE :   int					  =							torch.tensor([75, 75, 63, 65, 17, 17]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["class_labels"]   ,   a						)						)
				# verify orig_size
				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							torch.tensor([480, 640]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["orig_size"]   ,   a						)						)
				# verify size
				SCREAMING_SNAKE_CASE :   Any					  =							torch.tensor([800, 1066]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["size"]   ,   a						)						)






			@slow
			def 				__UpperCamelCase			(      self				:			str						)				->							str:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						)
				with open("./tests/fixtures/tests_samples/COCO/coco_panoptic_annotations.txt"   ,   "r"						) as f:
					SCREAMING_SNAKE_CASE :   Dict					  =							json.loads(f.read()						)

				SCREAMING_SNAKE_CASE :   Tuple					  =							{"file_name": "000000039769.png", "image_id": 3_9769, "segments_info": target}

				SCREAMING_SNAKE_CASE :   str					  =							pathlib.Path("./tests/fixtures/tests_samples/COCO/coco_panoptic"						)

				# encode them
				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							DeformableDetrImageProcessor(format="coco_panoptic"						)
				SCREAMING_SNAKE_CASE :   int					  =							image_processing(images=a   ,   annotations=a   ,   masks_path=a   ,   return_tensors="pt"						)

				# verify pixel values
				SCREAMING_SNAKE_CASE :   Dict					  =							torch.Size([1, 3, 800, 1066]						)
				self.assertEqual(encoding["pixel_values"].shape   ,   a						)

				SCREAMING_SNAKE_CASE :   str					  =							torch.tensor([0.2796, 0.3138, 0.3481]						)
				self.assertTrue(torch.allclose(encoding["pixel_values"][0, 0, 0, :3]   ,   a   ,   atol=1e-4						)						)

				# verify area
				SCREAMING_SNAKE_CASE :   str					  =							torch.tensor([14_7979.6875, 16_5527.0469, 48_4638.5938, 1_1292.9375, 5879.6562, 7634.1147]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["area"]   ,   a						)						)
				# verify boxes
				SCREAMING_SNAKE_CASE :   Dict					  =							torch.Size([6, 4]						)
				self.assertEqual(encoding["labels"][0]["boxes"].shape   ,   a						)
				SCREAMING_SNAKE_CASE :   int					  =							torch.tensor([0.2625, 0.5437, 0.4688, 0.8625]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["boxes"][0]   ,   a   ,   atol=1e-3						)						)
				# verify image_id
				SCREAMING_SNAKE_CASE :   Any					  =							torch.tensor([3_9769]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["image_id"]   ,   a						)						)
				# verify is_crowd
				SCREAMING_SNAKE_CASE :   Dict					  =							torch.tensor([0, 0, 0, 0, 0, 0]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["iscrowd"]   ,   a						)						)
				# verify class_labels
				SCREAMING_SNAKE_CASE :   Tuple					  =							torch.tensor([17, 17, 63, 75, 75, 93]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["class_labels"]   ,   a						)						)
				# verify masks
				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							82_2873
				self.assertEqual(encoding["labels"][0]["masks"].sum().item()   ,   a						)
				# verify orig_size
				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							torch.tensor([480, 640]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["orig_size"]   ,   a						)						)
				# verify size
				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							torch.tensor([800, 1066]						)
				self.assertTrue(torch.allclose(encoding["labels"][0]["size"]   ,   a						)						)


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

import numpy as np
import pyarrow as pa

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


if TYPE_CHECKING:
			import jax
			import jaxlib

a_      =     get_logger()

a_      =     None






class _UpperCamelCase				(				TensorFormatter[Mapping, 'jax.Array', Mapping] ):
			'''simple docstring'''







			def __init__(      self				:			Optional[Any]   ,   a				:			str=None   ,   a				:			List[Any]=None   ,   **a				:			Any						)				->							Optional[Any]:

				"""simple docstring"""

				super().__init__(features=a						)
				import jax
				from jaxlib.xla_client import Device

				if isinstance(a   ,   a						):
					raise ValueError(
					    F"Expected {device} to be a `str` not {type(a						)}, as `jaxlib.xla_extension.Device` "
					    "is not serializable neither with `pickle` nor with `dill`. Instead you can surround "
					    "the device with `str()` to get its string identifier that will be internally mapped "
					    "to the actual `jaxlib.xla_extension.Device`."						)
				SCREAMING_SNAKE_CASE :   List[str]					  =							device if isinstance(a   ,   a						) else str(jax.devices()[0]						)
				# using global variable since `jaxlib.xla_extension.Device` is not serializable neither
				# with `pickle` nor with `dill`, so we need to use a global variable instead
				global DEVICE_MAPPING
				if DEVICE_MAPPING is None:
					SCREAMING_SNAKE_CASE :   str					  =							self._map_devices_to_str()
				if self.device not in list(DEVICE_MAPPING.keys()						):
					logger.warning(
					    F"Device with string identifier {self.device} not listed among the available "
					    F"devices: {list(DEVICE_MAPPING.keys()						)}, so falling back to the default "
					    F"device: {str(jax.devices()[0]						)}."						)
					SCREAMING_SNAKE_CASE :   Any					  =							str(jax.devices()[0]						)
				SCREAMING_SNAKE_CASE :   Any					  =							jnp_array_kwargs
			@staticmethod
			def 				__UpperCamelCase			(      )				->							Dict[str, "jaxlib.xla_extension.Device"]:

				"""simple docstring"""

				import jax

				return {str(a						): device for device in jax.devices()}
			def 				__UpperCamelCase			(      self				:			Dict   ,   a				:			Tuple						)				->							str:

				"""simple docstring"""

				import jax
				import jax.numpy as jnp

				if isinstance(a   ,   a						) and column:
					if all(
					    isinstance(a   ,   jax.Array						) and x.shape == column[0].shape and x.dtype == column[0].dtype for x in column						):
						return jnp.stack(a   ,   axis=0						)
				return column
			def 				__UpperCamelCase			(      self				:			Dict   ,   a				:			str						)				->							str:

				"""simple docstring"""

				import jax
				import jax.numpy as jnp

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

				SCREAMING_SNAKE_CASE :   Union[str, Any]					  =							{}

				if isinstance(a   ,   (np.number, np.ndarray)						) and np.issubdtype(value.dtype   ,   np.integer						):
					# the default int precision depends on the jax config
					# see https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html#double-64bit-precision
					if jax.config.jax_enable_xaa:
						SCREAMING_SNAKE_CASE :   Dict					  =							{"dtype": jnp.intaa}
					else:
						SCREAMING_SNAKE_CASE :   str					  =							{"dtype": jnp.intaa}
				elif isinstance(a   ,   (np.number, np.ndarray)						) and np.issubdtype(value.dtype   ,   np.floating						):
					SCREAMING_SNAKE_CASE :   int					  =							{"dtype": jnp.floataa}
				elif config.PIL_AVAILABLE and "PIL" in sys.modules:
					import PIL.Image

					if isinstance(a   ,   PIL.Image.Image						):
						SCREAMING_SNAKE_CASE :   Dict					  =							np.asarray(a						)

        # using global variable since `jaxlib.xla_extension.Device` is not serializable neither
        # with `pickle` nor with `dill`, so we need to use a global variable instead
				global DEVICE_MAPPING
				if DEVICE_MAPPING is None:
					SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self._map_devices_to_str()

				with jax.default_device(DEVICE_MAPPING[self.device]						):
					# calling jnp.array on a np.ndarray does copy the data
					# see https://github.com/google/jax/issues/4486
					return jnp.array(a   ,   **{**default_dtype, **self.jnp_array_kwargs}						)
			def 				__UpperCamelCase			(      self				:			Any   ,   a				:			List[str]						)				->							Dict:

				"""simple docstring"""

				import jax

				# support for torch, tf, jax etc.
				if config.TORCH_AVAILABLE and "torch" in sys.modules:
					import torch

					if isinstance(a   ,   torch.Tensor						):
						return self._tensorize(data_struct.detach().cpu().numpy()[()]						)
				if hasattr(a   ,   "__array__"						) and not isinstance(a   ,   jax.Array						):
					SCREAMING_SNAKE_CASE :   Optional[int]					  =							data_struct.__array__()
				# support for nested types like struct of list of struct
				if isinstance(a   ,   np.ndarray						):
					if data_struct.dtype == object:  # jax arrays cannot be instantied from an array of objects
						return self._consolidate([self.recursive_tensorize(a						) for substruct in data_struct]						)
				elif isinstance(a   ,   (list, tuple)						):
					return self._consolidate([self.recursive_tensorize(a						) for substruct in data_struct]						)
				return self._tensorize(a						)
			def 				__UpperCamelCase			(      self				:			Optional[Any]   ,   a				:			dict						)				->							Dict:

				"""simple docstring"""

				return map_nested(self._recursive_tensorize   ,   a   ,   map_list=a						)
			def 				__UpperCamelCase			(      self				:			Dict   ,   a				:			pa.Table						)				->							Mapping:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self.numpy_arrow_extractor().extract_row(a						)
				SCREAMING_SNAKE_CASE :   List[Any]					  =							self.python_features_decoder.decode_row(a						)
				return self.recursive_tensorize(a						)
			def 				__UpperCamelCase			(      self				:			Optional[int]   ,   a				:			pa.Table						)				->							"jax.Array":

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   Optional[int]					  =							self.numpy_arrow_extractor().extract_column(a						)
				SCREAMING_SNAKE_CASE :   Optional[Any]					  =							self.python_features_decoder.decode_column(a   ,   pa_table.column_names[0]						)
				SCREAMING_SNAKE_CASE :   Tuple					  =							self.recursive_tensorize(a						)
				SCREAMING_SNAKE_CASE :   Optional[int]					  =							self._consolidate(a						)
				return column






			def 				__UpperCamelCase			(      self				:			List[Any]   ,   a				:			pa.Table						)				->							Mapping:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE :   str					  =							self.numpy_arrow_extractor().extract_batch(a						)
				SCREAMING_SNAKE_CASE :   str					  =							self.python_features_decoder.decode_batch(a						)
				SCREAMING_SNAKE_CASE :   List[Any]					  =							self.recursive_tensorize(a						)
				for column_name in batch:
					SCREAMING_SNAKE_CASE :   List[Any]					  =							self._consolidate(batch[column_name]						)
				return batch