

import unittest

from transformers import GPTNeoXJapaneseConfig, is_torch_available
from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
						import torch

						from transformers import GPTNeoXJapaneseForCausalLM, GPTNeoXJapaneseModel



class   __lowercase    :




			"""simple docstring"""







			def __init__(			self  :					int       ,						lowerCAmelCase__  :					int       ,						lowerCAmelCase__  :					int=13       ,						lowerCAmelCase__  :					Optional[int]=7       ,						lowerCAmelCase__  :					List[str]=True       ,						lowerCAmelCase__  :					Optional[Any]=True       ,						lowerCAmelCase__  :					int=True       ,						lowerCAmelCase__  :					List[Any]=True       ,						lowerCAmelCase__  :					int=99       ,						lowerCAmelCase__  :					int=32       ,						lowerCAmelCase__  :					Union[str, Any]=5       ,						lowerCAmelCase__  :					Union[str, Any]=4       ,						lowerCAmelCase__  :					Tuple=4       ,						lowerCAmelCase__  :					Any="gelu"       ,						lowerCAmelCase__  :					str=0.0       ,						lowerCAmelCase__  :					Any=0.1       ,						lowerCAmelCase__  :					Optional[Any]=True       ,						lowerCAmelCase__  :					Dict=512       ,						lowerCAmelCase__  :					List[str]=16       ,						lowerCAmelCase__  :					Any=2       ,						lowerCAmelCase__  :					Optional[Any]=0.02       ,						lowerCAmelCase__  :					Tuple=3       ,						lowerCAmelCase__  :					List[Any]=4       ,						lowerCAmelCase__  :					str=None       ,						):
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	parent
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	batch_size
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	seq_length
									SCREAMING_SNAKE_CASE_:			Tuple  		=	is_training
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	use_input_mask
									SCREAMING_SNAKE_CASE_:			Any  		=	use_token_type_ids
									SCREAMING_SNAKE_CASE_:			Any  		=	use_labels
									SCREAMING_SNAKE_CASE_:			Dict  		=	vocab_size
									SCREAMING_SNAKE_CASE_:			Tuple  		=	hidden_size
									SCREAMING_SNAKE_CASE_:			Dict  		=	num_hidden_layers
									SCREAMING_SNAKE_CASE_:			Tuple  		=	num_attention_heads
									SCREAMING_SNAKE_CASE_:			Any  		=	intermediate_multiple_size
									SCREAMING_SNAKE_CASE_:			str  		=	hidden_act
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	hidden_dropout
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	attention_dropout
									SCREAMING_SNAKE_CASE_:			List[str]  		=	weight_tying
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	max_position_embeddings
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	type_vocab_size
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	type_sequence_label_size
									SCREAMING_SNAKE_CASE_:			str  		=	initializer_range
									SCREAMING_SNAKE_CASE_:			Any  		=	num_labels
									SCREAMING_SNAKE_CASE_:			str  		=	num_choices
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	scope



			def 	_SCREAMING_SNAKE_CASE      (			self  :					List[Any]):
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	ids_tensor([self.batch_size, self.seq_length]       ,						self.vocab_size)

									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	None
									if self.use_input_mask:
															SCREAMING_SNAKE_CASE_:			str  		=	random_attention_mask([self.batch_size, self.seq_length])

									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	None
									if self.use_labels:
															SCREAMING_SNAKE_CASE_:			Tuple  		=	ids_tensor([self.batch_size, self.seq_length]       ,						self.num_labels)

									SCREAMING_SNAKE_CASE_:			int  		=	self.get_config()

									return config, input_ids, input_mask, token_labels



			def 	_SCREAMING_SNAKE_CASE      (			self  :					str):
									return GPTNeoXJapaneseConfig(
									    vocab_size=self.vocab_size       ,						hidden_size=self.hidden_size       ,						num_hidden_layers=self.num_hidden_layers       ,						num_attention_heads=self.num_attention_heads       ,						intermediate_multiple_size=self.intermediate_multiple_size       ,						hidden_act=self.hidden_act       ,						hidden_dropout=self.hidden_dropout       ,						attention_dropout=self.attention_dropout       ,						weight_tying=self.weight_tying       ,						max_position_embeddings=self.max_position_embeddings       ,						type_vocab_size=self.type_vocab_size       ,						is_decoder=lowerCAmelCase__       ,						initializer_range=self.initializer_range       ,						)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Optional[Any]):
									SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_:			Dict  		=	self.prepare_config_and_inputs()

									SCREAMING_SNAKE_CASE_:			List[str]  		=	True

									return config, input_ids, input_mask, token_labels



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Any       ,						lowerCAmelCase__  :					Optional[Any]       ,						lowerCAmelCase__  :					Tuple       ,						lowerCAmelCase__  :					str):
									SCREAMING_SNAKE_CASE_:			Dict  		=	GPTNeoXJapaneseModel(config=lowerCAmelCase__)
									model.to(lowerCAmelCase__)
									model.eval()
									SCREAMING_SNAKE_CASE_:			Any  		=	model(lowerCAmelCase__       ,						attention_mask=lowerCAmelCase__)
									SCREAMING_SNAKE_CASE_:			Dict  		=	model(lowerCAmelCase__)
									self.parent.assertEqual(result.last_hidden_state.shape       ,						(self.batch_size, self.seq_length, self.hidden_size))



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Optional[int]       ,						lowerCAmelCase__  :					Tuple       ,						lowerCAmelCase__  :					Tuple       ,						lowerCAmelCase__  :					List[Any]):
									SCREAMING_SNAKE_CASE_:			List[str]  		=	True
									SCREAMING_SNAKE_CASE_:			int  		=	GPTNeoXJapaneseModel(lowerCAmelCase__)
									model.to(lowerCAmelCase__)
									model.eval()
									SCREAMING_SNAKE_CASE_:			List[str]  		=	model(lowerCAmelCase__       ,						attention_mask=lowerCAmelCase__)
									self.parent.assertEqual(result.last_hidden_state.shape       ,						(self.batch_size, self.seq_length, self.hidden_size))



			def 	_SCREAMING_SNAKE_CASE      (			self  :					str       ,						lowerCAmelCase__  :					int       ,						lowerCAmelCase__  :					Dict       ,						lowerCAmelCase__  :					Any       ,						lowerCAmelCase__  :					List[Any]):
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	GPTNeoXJapaneseForCausalLM(config=lowerCAmelCase__)
									model.to(lowerCAmelCase__)
									model.eval()
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	model(lowerCAmelCase__       ,						attention_mask=lowerCAmelCase__       ,						labels=lowerCAmelCase__)
									self.parent.assertEqual(result.logits.shape       ,						(self.batch_size, self.seq_length, self.vocab_size))



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Any       ,						lowerCAmelCase__  :					int       ,						lowerCAmelCase__  :					int       ,						lowerCAmelCase__  :					Dict):
									SCREAMING_SNAKE_CASE_:			Any  		=	True
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	GPTNeoXJapaneseForCausalLM(config=lowerCAmelCase__)
									model.to(lowerCAmelCase__)
									model.eval()

									# first forward pass
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	model(lowerCAmelCase__       ,						attention_mask=lowerCAmelCase__       ,						use_cache=lowerCAmelCase__)
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	outputs.past_key_values

									# create hypothetical multiple next token and extent to next_input_ids
									SCREAMING_SNAKE_CASE_:			Dict  		=	ids_tensor((self.batch_size, 3)       ,						config.vocab_size)
									SCREAMING_SNAKE_CASE_:			str  		=	ids_tensor((self.batch_size, 3)       ,						vocab_size=2)

									# append to next input_ids and
									SCREAMING_SNAKE_CASE_:			Dict  		=	torch.cat([input_ids, next_tokens]       ,						dim=-1)
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	torch.cat([input_mask, next_mask]       ,						dim=-1)

									SCREAMING_SNAKE_CASE_:			List[str]  		=	model(lowerCAmelCase__       ,						attention_mask=lowerCAmelCase__       ,						output_hidden_states=lowerCAmelCase__)
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	output_from_no_past["hidden_states"][0]
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	model(
									    lowerCAmelCase__       ,						attention_mask=lowerCAmelCase__       ,						past_key_values=lowerCAmelCase__       ,						output_hidden_states=lowerCAmelCase__       ,						)["hidden_states"][0]

									# select random slice
									SCREAMING_SNAKE_CASE_:			Tuple  		=	ids_tensor((1,)       ,						output_from_past.shape[-1]).item()
									SCREAMING_SNAKE_CASE_:			List[str]  		=	output_from_no_past[:, -3:, random_slice_idx].detach()
									SCREAMING_SNAKE_CASE_:			Tuple  		=	output_from_past[:, :, random_slice_idx].detach()

									self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1])

									# test that outputs are equal for slice
									self.parent.assertTrue(torch.allclose(lowerCAmelCase__       ,						lowerCAmelCase__       ,						atol=1E-3))




			def 	_SCREAMING_SNAKE_CASE      (			self  :					str):
									SCREAMING_SNAKE_CASE_:			List[str]  		=	self.prepare_config_and_inputs()
									SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_:			Any  		=	config_and_inputs
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	{"input_ids": input_ids, "attention_mask": input_mask}
									return config, inputs_dict







@require_torch
class   __lowercase    (			UpperCAmelCase_		,	UpperCAmelCase_		,	unittest.TestCase     ):




			"""simple docstring"""







			_UpperCAmelCase       :							Optional[Any]      							=					(GPTNeoXJapaneseModel, GPTNeoXJapaneseForCausalLM) if is_torch_available() else ()
			_UpperCAmelCase       :							int      							=					(GPTNeoXJapaneseForCausalLM,) if is_torch_available() else ()
			_UpperCAmelCase       :							Optional[int]      							=					(
			    {'''feature-extraction''': GPTNeoXJapaneseModel, '''text-generation''': GPTNeoXJapaneseForCausalLM}
			    if is_torch_available()
			    else {}
			)
			_UpperCAmelCase       :							str      							=					False
			_UpperCAmelCase       :							Tuple      							=					False
			_UpperCAmelCase       :							Any      							=					False
			_UpperCAmelCase       :							Dict      							=					False



			def 	_SCREAMING_SNAKE_CASE      (			self  :					List[Any]):
									SCREAMING_SNAKE_CASE_:			int  		=	GPTNeoXJapaneseModelTester(self)
									SCREAMING_SNAKE_CASE_:			Any  		=	ConfigTester(self       ,						config_class=lowerCAmelCase__       ,						hidden_size=37)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Tuple):
									self.config_tester.run_common_tests()



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Any):
									SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_:			int  		=	self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(lowerCAmelCase__       ,						lowerCAmelCase__       ,						lowerCAmelCase__)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Dict):
									SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_:			Dict  		=	self.model_tester.prepare_config_and_inputs_for_decoder()
									self.model_tester.create_and_check_model_as_decoder(lowerCAmelCase__       ,						lowerCAmelCase__       ,						lowerCAmelCase__)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					List[str]):
									# This regression test was failing with PyTorch < 1.3
									SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_:			Dict  		=	self.model_tester.prepare_config_and_inputs_for_decoder()

									SCREAMING_SNAKE_CASE_:			str  		=	None

									self.model_tester.create_and_check_model_as_decoder(lowerCAmelCase__       ,						lowerCAmelCase__       ,						lowerCAmelCase__)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					str):
									SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_		,   SCREAMING_SNAKE_CASE_:			Dict  		=	self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_decoder_model_past_large_inputs(lowerCAmelCase__       ,						lowerCAmelCase__       ,						lowerCAmelCase__)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Union[str, Any]):
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_causal_lm(*lowerCAmelCase__)




			@slow
			def 	_SCREAMING_SNAKE_CASE      (			self  :					str):
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	"abeja/gpt-neox-japanese-2.7b"

									SCREAMING_SNAKE_CASE_:			List[str]  		=	["データサイエンティストとは、", "100年後に必要とされる会社は、", "フルリモートの環境で働くために必要なことは、", "国境の長いトンネルを抜けると", "美味しい日本食といえば、"]

									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	[
									    "データサイエンティストとは、データを分析し、ビジネスに役立つ知見を導き出す専門家のことです。",
									    "100年後に必要とされる会社は、「人」が中心の会社です。",
									    "フルリモートの環境で働くために必要なことは、「自分の時間をコントロールする」ことです。",
									    "国境の長いトンネルを抜けると、そこは雪国だった。",
									    "美味しい日本食といえば、やっぱりお寿司ですよね。",
									]

									SCREAMING_SNAKE_CASE_:			Any  		=	GPTNeoXJapaneseTokenizer.from_pretrained(lowerCAmelCase__)
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	GPTNeoXJapaneseForCausalLM.from_pretrained(lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			List[Any]  		=	[]
									for prompt in prompts:
															SCREAMING_SNAKE_CASE_:			Tuple  		=	tokenizer(lowerCAmelCase__       ,						return_tensors="pt").input_ids
															SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	model.generate(lowerCAmelCase__       ,						max_length=50)
															SCREAMING_SNAKE_CASE_:			Tuple  		=	tokenizer.batch_decode(lowerCAmelCase__       ,						skip_special_tokens=lowerCAmelCase__)
															predicted_outputs += generated_string
									self.assertListEqual(lowerCAmelCase__       ,						lowerCAmelCase__)









from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
						import PIL


lowerCAmelCase							:  Optional[Any]            =						logging.get_logger(__name__)



class   __lowercase    (			UpperCAmelCase_     ):




			"""simple docstring"""







			_UpperCAmelCase       :							Any      							=					['''pixel_values''']



			def __init__(			self  :					List[Any]       ,						lowerCAmelCase__  :					bool = True       ,						lowerCAmelCase__  :					Dict[str, int] = None       ,						lowerCAmelCase__  :					PILImageResampling = PILImageResampling.BICUBIC       ,						lowerCAmelCase__  :					bool = True       ,						lowerCAmelCase__  :					Union[int, float] = 1 / 255       ,						lowerCAmelCase__  :					bool = True       ,						lowerCAmelCase__  :					Optional[Union[float, List[float]]] = None       ,						lowerCAmelCase__  :					Optional[Union[float, List[float]]] = None       ,						lowerCAmelCase__  :					bool = True       ,						**lowerCAmelCase__  :					Tuple       ,						):
									super().__init__(**lowerCAmelCase__)
									SCREAMING_SNAKE_CASE_:			List[str]  		=	size if size is not None else {"height": 384, "width": 384}
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	get_size_dict(lowerCAmelCase__       ,						default_to_square=lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			int  		=	do_resize
									SCREAMING_SNAKE_CASE_:			Dict  		=	size
									SCREAMING_SNAKE_CASE_:			int  		=	resample
									SCREAMING_SNAKE_CASE_:			str  		=	do_rescale
									SCREAMING_SNAKE_CASE_:			str  		=	rescale_factor
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	do_normalize
									SCREAMING_SNAKE_CASE_:			Union[str, Any]  		=	image_mean if image_mean is not None else OPENAI_CLIP_MEAN
									SCREAMING_SNAKE_CASE_:			List[str]  		=	image_std if image_std is not None else OPENAI_CLIP_STD
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	do_convert_rgb



			def 	_SCREAMING_SNAKE_CASE      (			self  :					str       ,						lowerCAmelCase__  :					np.ndarray       ,						lowerCAmelCase__  :					Dict[str, int]       ,						lowerCAmelCase__  :					PILImageResampling = PILImageResampling.BICUBIC       ,						lowerCAmelCase__  :					Optional[Union[str, ChannelDimension]] = None       ,						**lowerCAmelCase__  :					Tuple       ,						):
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	get_size_dict(lowerCAmelCase__       ,						default_to_square=lowerCAmelCase__)
									if "height" not in size or "width" not in size:
															raise ValueError(F"The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}")
									SCREAMING_SNAKE_CASE_:			int  		=	(size["height"], size["width"])
									return resize(lowerCAmelCase__       ,						size=lowerCAmelCase__       ,						resample=lowerCAmelCase__       ,						data_format=lowerCAmelCase__       ,						**lowerCAmelCase__)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					Tuple       ,						lowerCAmelCase__  :					np.ndarray       ,						lowerCAmelCase__  :					Union[int, float]       ,						lowerCAmelCase__  :					Optional[Union[str, ChannelDimension]] = None       ,						**lowerCAmelCase__  :					List[Any]       ,						):
									return rescale(lowerCAmelCase__       ,						scale=lowerCAmelCase__       ,						data_format=lowerCAmelCase__       ,						**lowerCAmelCase__)



			def 	_SCREAMING_SNAKE_CASE      (			self  :					List[str]       ,						lowerCAmelCase__  :					np.ndarray       ,						lowerCAmelCase__  :					Union[float, List[float]]       ,						lowerCAmelCase__  :					Union[float, List[float]]       ,						lowerCAmelCase__  :					Optional[Union[str, ChannelDimension]] = None       ,						**lowerCAmelCase__  :					List[Any]       ,						):
									return normalize(lowerCAmelCase__       ,						mean=lowerCAmelCase__       ,						std=lowerCAmelCase__       ,						data_format=lowerCAmelCase__       ,						**lowerCAmelCase__)




			def 	_SCREAMING_SNAKE_CASE      (			self  :					Union[str, Any]       ,						lowerCAmelCase__  :					ImageInput       ,						lowerCAmelCase__  :					Optional[bool] = None       ,						lowerCAmelCase__  :					Optional[Dict[str, int]] = None       ,						lowerCAmelCase__  :					PILImageResampling = None       ,						lowerCAmelCase__  :					Optional[bool] = None       ,						lowerCAmelCase__  :					Optional[float] = None       ,						lowerCAmelCase__  :					Optional[bool] = None       ,						lowerCAmelCase__  :					Optional[Union[float, List[float]]] = None       ,						lowerCAmelCase__  :					Optional[Union[float, List[float]]] = None       ,						lowerCAmelCase__  :					Optional[Union[str, TensorType]] = None       ,						lowerCAmelCase__  :					bool = None       ,						lowerCAmelCase__  :					ChannelDimension = ChannelDimension.FIRST       ,						**lowerCAmelCase__  :					Dict       ,						):
									SCREAMING_SNAKE_CASE_:			Any  		=	do_resize if do_resize is not None else self.do_resize
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	resample if resample is not None else self.resample
									SCREAMING_SNAKE_CASE_:			Dict  		=	do_rescale if do_rescale is not None else self.do_rescale
									SCREAMING_SNAKE_CASE_:			Any  		=	rescale_factor if rescale_factor is not None else self.rescale_factor
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	do_normalize if do_normalize is not None else self.do_normalize
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	image_mean if image_mean is not None else self.image_mean
									SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	image_std if image_std is not None else self.image_std
									SCREAMING_SNAKE_CASE_:			Optional[int]  		=	do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

									SCREAMING_SNAKE_CASE_:			str  		=	size if size is not None else self.size
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	get_size_dict(lowerCAmelCase__       ,						default_to_square=lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:			List[Any]  		=	make_list_of_images(lowerCAmelCase__)

									if not valid_images(lowerCAmelCase__):
															raise ValueError(
															    "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
															    "torch.Tensor, tf.Tensor or jax.ndarray.")

									if do_resize and size is None or resample is None:
															raise ValueError("Size and resample must be specified if do_resize is True.")

									if do_rescale and rescale_factor is None:
															raise ValueError("Rescale factor must be specified if do_rescale is True.")

									if do_normalize and (image_mean is None or image_std is None):
															raise ValueError("Image mean and std must be specified if do_normalize is True.")

									# PIL RGBA images are converted to RGB
									if do_convert_rgb:
															SCREAMING_SNAKE_CASE_:			List[Any]  		=	[convert_to_rgb(lowerCAmelCase__) for image in images]

									# All transformations expect numpy arrays.
									SCREAMING_SNAKE_CASE_:			List[Any]  		=	[to_numpy_array(lowerCAmelCase__) for image in images]

									if do_resize:
															SCREAMING_SNAKE_CASE_:			int  		=	[self.resize(image=lowerCAmelCase__       ,						size=lowerCAmelCase__       ,						resample=lowerCAmelCase__) for image in images]

									if do_rescale:
															SCREAMING_SNAKE_CASE_:			Optional[Any]  		=	[self.rescale(image=lowerCAmelCase__       ,						scale=lowerCAmelCase__) for image in images]

									if do_normalize:
															SCREAMING_SNAKE_CASE_:			List[str]  		=	[self.normalize(image=lowerCAmelCase__       ,						mean=lowerCAmelCase__       ,						std=lowerCAmelCase__) for image in images]

									SCREAMING_SNAKE_CASE_:			str  		=	[to_channel_dimension_format(lowerCAmelCase__       ,						lowerCAmelCase__) for image in images]

									SCREAMING_SNAKE_CASE_:			List[str]  		=	BatchFeature(data={"pixel_values": images}       ,						tensor_type=lowerCAmelCase__)

									return encoded_outputs






