


"""simple docstring"""
from abc import ABC, abstractmethod
from typing import List, Optional





class      __A     (snake_case__):





							'''simple docstring'''

							def __init__(				self							:      Any       )					->Tuple:



														"""simple docstring"""



														self.test()



							def 		lowerCAmelCase       (				self							:      List[str]       )					->str:



														"""simple docstring"""



														snake_case_           =		0
														snake_case_           =		False
														while not completed:
																					if counter == 1:
																												self.reset()
																					snake_case_           =		self.advance()
																					if not self.does_advance(UpperCAmelCase_       ):
																												raise Exception(
																												    """Custom Constraint is not defined correctly. self.does_advance(self.advance()) must be true."""       )

																					snake_case_       ,						snake_case_       ,						snake_case_           =		self.update(UpperCAmelCase_       )
																					counter += 1

																					if counter > 10_000:
																												raise Exception("""update() does not fulfill the constraint."""       )

														if self.remaining() != 0:
																					raise Exception("""Custom Constraint is not defined correctly."""       )



							@abstractmethod
							def 		lowerCAmelCase       (				self							:      List[Any]       )					->Optional[Any]:



														"""simple docstring"""



														raise NotImplementedError(
														    F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""       )



							@abstractmethod
							def 		lowerCAmelCase       (				self							:      Dict		,       UpperCAmelCase_							:      int       )					->Tuple:



														"""simple docstring"""



														raise NotImplementedError(
														    F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""       )



							@abstractmethod
							def 		lowerCAmelCase       (				self							:      List[Any]		,       UpperCAmelCase_							:      int       )					->List[str]:



														"""simple docstring"""



														raise NotImplementedError(
														    F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""       )



							@abstractmethod
							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->int:



														"""simple docstring"""



														raise NotImplementedError(
														    F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""       )



							@abstractmethod
							def 		lowerCAmelCase       (				self							:      Any       )					->List[str]:



														"""simple docstring"""



														raise NotImplementedError(
														    F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""       )



							@abstractmethod
							def 		lowerCAmelCase       (				self							:      List[Any]		,       UpperCAmelCase_							:      Optional[Any]=False       )					->List[Any]:



														"""simple docstring"""



														raise NotImplementedError(
														    F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""       )





class      __A     (snake_case__):





							'''simple docstring'''

							def __init__(				self							:      Dict		,       UpperCAmelCase_							:      List[int]       )					->str:



														"""simple docstring"""



														super(UpperCAmelCase_		,       self       ).__init__()

														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ) or len(UpperCAmelCase_       ) == 0:
																					raise ValueError(F"""`token_ids` has to be a non-empty list, but is {token_ids}."""       )
														if any((not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ) or token_id < 0) for token_id in token_ids       ):
																					raise ValueError(F"""Each list in `token_ids` has to be a list of positive integers, but is {token_ids}."""       )

														snake_case_           =		token_ids

														snake_case_           =		len(self.token_ids       )
														snake_case_           =		-1  # the index of the currently fulfilled step
														snake_case_           =		False



							def 		lowerCAmelCase       (				self							:      int       )					->Dict:



														"""simple docstring"""



														if self.completed:
																					return None
														return self.token_ids[self.fulfilled_idx + 1]



							def 		lowerCAmelCase       (				self							:      Tuple		,       UpperCAmelCase_							:      int       )					->Optional[int]:



														"""simple docstring"""



														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					raise ValueError(F"""`token_id` has to be an `int`, but is {token_id} of type {type(UpperCAmelCase_       )}"""       )

														if self.completed:
																					return False

														return token_id == self.token_ids[self.fulfilled_idx + 1]



							def 		lowerCAmelCase       (				self							:      Tuple		,       UpperCAmelCase_							:      int       )					->List[Any]:



														"""simple docstring"""



														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					raise ValueError(F"""`token_id` has to be an `int`, but is {token_id} of type {type(UpperCAmelCase_       )}"""       )

														snake_case_           =		False
														snake_case_           =		False
														snake_case_           =		False

														if self.does_advance(UpperCAmelCase_       ):
																					self.fulfilled_idx += 1
																					snake_case_           =		True
																					if self.fulfilled_idx == (self.seqlen - 1):
																												snake_case_           =		True
																					snake_case_           =		completed
														else:
																					# failed to make progress.
																					snake_case_           =		True
																					self.reset()
														return stepped, completed, reset



							def 		lowerCAmelCase       (				self							:      Dict       )					->Optional[Any]:



														"""simple docstring"""



														snake_case_           =		False
														snake_case_           =		0



							def 		lowerCAmelCase       (				self							:      List[Any]       )					->Dict:



														"""simple docstring"""



														return self.seqlen - (self.fulfilled_idx + 1)



							def 		lowerCAmelCase       (				self							:      Any		,       UpperCAmelCase_							:      Dict=False       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		PhrasalConstraint(self.token_ids       )

														if stateful:
																					snake_case_           =		self.seqlen
																					snake_case_           =		self.fulfilled_idx
																					snake_case_           =		self.completed

														return new_constraint





class      __A     :





							'''simple docstring'''

							def __init__(				self							:      Optional[Any]		,       UpperCAmelCase_							:      List[List[int]]		,       UpperCAmelCase_							:      Optional[int]=True       )					->Union[str, Any]:



														"""simple docstring"""



														snake_case_           =		max([len(UpperCAmelCase_       ) for one in nested_token_ids]       )

														snake_case_           =		{}
														for token_ids in nested_token_ids:
																					snake_case_           =		root
																					for tidx, token_id in enumerate(UpperCAmelCase_       ):
																												if token_id not in level:
																																			snake_case_           =		{}

																												snake_case_           =		level[token_id]

														if no_subsets and self.has_subsets(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					raise ValueError(
																					    """Each list in `nested_token_ids` can't be a complete subset of another list, but is"""
																					    F""" {nested_token_ids}."""       )

														snake_case_           =		root



							def 		lowerCAmelCase       (				self							:      Optional[Any]		,       UpperCAmelCase_							:      Optional[int]       )					->Optional[Any]:



														"""simple docstring"""



														snake_case_           =		self.trie

														for current_token in current_seq:
																					snake_case_           =		start[current_token]

														snake_case_           =		list(start.keys()       )

														return next_tokens



							def 		lowerCAmelCase       (				self							:      str		,       UpperCAmelCase_							:      int       )					->Optional[int]:



														"""simple docstring"""



														snake_case_           =		self.next_tokens(UpperCAmelCase_       )

														return len(UpperCAmelCase_       ) == 0



							def 		lowerCAmelCase       (				self							:      int		,       UpperCAmelCase_							:      Dict       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		list(root.values()       )
														if len(UpperCAmelCase_       ) == 0:
																					return 1
														else:
																					return sum([self.count_leaves(UpperCAmelCase_       ) for nn in next_nodes]       )



							def 		lowerCAmelCase       (				self							:      str		,       UpperCAmelCase_							:      Union[str, Any]		,       UpperCAmelCase_							:      Union[str, Any]       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		self.count_leaves(UpperCAmelCase_       )
														return len(UpperCAmelCase_       ) != leaf_count





class      __A     (snake_case__):





							'''simple docstring'''

							def __init__(				self							:      Optional[int]		,       UpperCAmelCase_							:      List[List[int]]       )					->List[str]:



														"""simple docstring"""



														super(UpperCAmelCase_		,       self       ).__init__()

														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ) or len(UpperCAmelCase_       ) == 0:
																					raise ValueError(F"""`nested_token_ids` has to be a non-empty list, but is {nested_token_ids}."""       )
														if any(not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ) for token_ids in nested_token_ids       ):
																					raise ValueError(F"""`nested_token_ids` has to be a list of lists, but is {nested_token_ids}."""       )
														if any(
														    any((not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ) or token_id < 0) for token_id in token_ids       )
														    for token_ids in nested_token_ids       ):
																					raise ValueError(
																					    F"""Each list in `nested_token_ids` has to be a list of positive integers, but is {nested_token_ids}."""       )

														snake_case_           =		DisjunctiveTrie(UpperCAmelCase_       )
														snake_case_           =		nested_token_ids

														snake_case_           =		self.trie.max_height
														snake_case_           =		[]
														snake_case_           =		False



							def 		lowerCAmelCase       (				self							:      List[str]       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		self.trie.next_tokens(self.current_seq       )

														if len(UpperCAmelCase_       ) == 0:
																					return None
														else:
																					return token_list



							def 		lowerCAmelCase       (				self							:      Union[str, Any]		,       UpperCAmelCase_							:      int       )					->int:



														"""simple docstring"""



														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					raise ValueError(F"""`token_id` is supposed to be type `int`, but is {token_id} of type {type(UpperCAmelCase_       )}"""       )

														snake_case_           =		self.trie.next_tokens(self.current_seq       )

														return token_id in next_tokens



							def 		lowerCAmelCase       (				self							:      Optional[Any]		,       UpperCAmelCase_							:      int       )					->Dict:



														"""simple docstring"""



														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					raise ValueError(F"""`token_id` is supposed to be type `int`, but is {token_id} of type {type(UpperCAmelCase_       )}"""       )

														snake_case_           =		False
														snake_case_           =		False
														snake_case_           =		False

														if self.does_advance(UpperCAmelCase_       ):
																					self.current_seq.append(UpperCAmelCase_       )
																					snake_case_           =		True
														else:
																					snake_case_           =		True
																					self.reset()

														snake_case_           =		self.trie.reached_leaf(self.current_seq       )
														snake_case_           =		completed

														return stepped, completed, reset



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->Dict:



														"""simple docstring"""



														snake_case_           =		False
														snake_case_           =		[]



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->int:



														"""simple docstring"""



														if self.completed:
																					# since this can be completed without reaching max height
																					return 0
														else:
																					return self.seqlen - len(self.current_seq       )



							def 		lowerCAmelCase       (				self							:      str		,       UpperCAmelCase_							:      Optional[Any]=False       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		DisjunctiveConstraint(self.token_ids       )

														if stateful:
																					snake_case_           =		self.seqlen
																					snake_case_           =		self.current_seq
																					snake_case_           =		self.completed

														return new_constraint





class      __A     :





							'''simple docstring'''

							def __init__(				self							:      str		,       UpperCAmelCase_							:      List[Constraint]       )					->Any:



														"""simple docstring"""



														snake_case_           =		constraints

														# max # of steps required to fulfill a given constraint
														snake_case_           =		max([c.seqlen for c in constraints]       )
														snake_case_           =		len(UpperCAmelCase_       )
														snake_case_           =		False

														self.init_state()



							def 		lowerCAmelCase       (				self							:      int       )					->Dict:



														"""simple docstring"""



														snake_case_           =		[]
														snake_case_           =		None
														snake_case_           =		[constraint.copy(stateful=UpperCAmelCase_       ) for constraint in self.constraints]



							def 		lowerCAmelCase       (				self							:      List[Any]       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		0
														if self.inprogress_constraint:
																					# extra points for having a constraint mid-fulfilled
																					add += self.max_seqlen - self.inprogress_constraint.remaining()

														return (len(self.complete_constraints       ) * self.max_seqlen) + add



							def 		lowerCAmelCase       (				self							:      str       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		[]
														if self.inprogress_constraint is None:
																					for constraint in self.pending_constraints:  # "pending" == "unfulfilled yet"
																												snake_case_           =		constraint.advance()
																												if isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																																			token_list.append(UpperCAmelCase_       )
																												elif isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																																			token_list.extend(UpperCAmelCase_       )
														else:
																					snake_case_           =		self.inprogress_constraint.advance()
																					if isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																												token_list.append(UpperCAmelCase_       )
																					elif isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																												token_list.extend(UpperCAmelCase_       )

														if len(UpperCAmelCase_       ) == 0:
																					return None
														else:
																					return token_list



							def 		lowerCAmelCase       (				self							:      Optional[int]		,       UpperCAmelCase_							:      Optional[List[int]]       )					->Dict:



														"""simple docstring"""



														self.init_state()

														if token_ids is not None:
																					for token in token_ids:
																												# completes or steps **one** constraint
																												snake_case_       ,						snake_case_           =		self.add(UpperCAmelCase_       )

																												# the entire list of constraints are fulfilled
																												if self.completed:
																																			break



							def 		lowerCAmelCase       (				self							:      Union[str, Any]		,       UpperCAmelCase_							:      int       )					->List[Any]:



														"""simple docstring"""



														if not isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					raise ValueError(F"""`token_id` should be an `int`, but is `{token_id}`."""       )

														snake_case_       ,						snake_case_           =		False, False

														if self.completed:
																					snake_case_           =		True
																					snake_case_           =		False
																					return complete, stepped

														if self.inprogress_constraint is not None:
																					# In the middle of fulfilling a constraint. If the `token_id` *does* makes an incremental progress to current
																					# job, simply update the state

																					snake_case_       ,						snake_case_       ,						snake_case_           =		self.inprogress_constraint.update(UpperCAmelCase_       )
																					if reset:
																												# 1. If the next token breaks the progress, then we must restart.
																												#     e.g. constraint = "I love pies" and sequence so far is "I love" but `token_id` == "books".

																												#     But that doesn't mean we self.init_state(), since we only reset the state for this particular
																												#     constraint, not the full list of constraints.

																												self.pending_constraints.append(self.inprogress_constraint.copy(stateful=UpperCAmelCase_       )       )
																												snake_case_           =		None

																					if complete:
																												# 2. If the next token completes the constraint, move it to completed list, set
																												#     inprogress to None. If there are no pending constraints either, then this full list of constraints
																												#     is complete.

																												self.complete_constraints.append(self.inprogress_constraint       )
																												snake_case_           =		None

																												if len(self.pending_constraints       ) == 0:
																																			# we're done!
																																			snake_case_           =		True

														else:
																					# Not in the middle of fulfilling a constraint. So does this `token_id` helps us step towards any of our list
																					# of constraints?

																					for cidx, pending_constraint in enumerate(self.pending_constraints       ):
																												if pending_constraint.does_advance(UpperCAmelCase_       ):
																																			snake_case_       ,						snake_case_       ,						snake_case_           =		pending_constraint.update(UpperCAmelCase_       )

																																			if not stepped:
																																										raise Exception(
																																										    """`constraint.update(token_id)` is not yielding incremental progress, """
																																										    """even though `constraint.does_advance(token_id)` is true."""       )

																																			if complete:
																																										self.complete_constraints.append(UpperCAmelCase_       )
																																										snake_case_           =		None

																																			if not complete and stepped:
																																										snake_case_           =		pending_constraint

																																			if complete or stepped:
																																										# If we made any progress at all, then it's at least not a "pending constraint".

																																										snake_case_           =		(
																																										    self.pending_constraints[:cidx] + self.pending_constraints[cidx + 1 :]
																																										)

																																										if len(self.pending_constraints       ) == 0 and self.inprogress_constraint is None:
																																																	# If there's no longer any pending after this and no inprogress either, then we must be
																																																	# complete.

																																																	snake_case_           =		True

																																										break  # prevent accidentally stepping through multiple constraints with just one token.

														return complete, stepped



							def 		lowerCAmelCase       (				self							:      Tuple		,       UpperCAmelCase_							:      Optional[Any]=True       )					->Optional[int]:



														"""simple docstring"""



														snake_case_           =		ConstraintListState(self.constraints       )  # we actually never though self.constraints objects
														# throughout this process. So it's at initialization state.

														if stateful:
																					snake_case_           =		[
																					    constraint.copy(stateful=UpperCAmelCase_       ) for constraint in self.complete_constraints
																					]
																					if self.inprogress_constraint is not None:
																												snake_case_           =		self.inprogress_constraint.copy(stateful=UpperCAmelCase_       )
																					snake_case_           =		[constraint.copy() for constraint in self.pending_constraints]

														return new_state







"""simple docstring"""
import json
import os
import tempfile
import unittest

import numpy as np
from datasets import load_dataset

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


if is_torch_available():
				import torch

if is_vision_available():
				from PIL import Image

				from transformers import ImageGPTImageProcessor





class      __A     (unittest.TestCase):





							'''simple docstring'''

							def __init__(				self							:      int		,       UpperCAmelCase_							:      List[str]		,       UpperCAmelCase_							:      Tuple=7		,       UpperCAmelCase_							:      Dict=3		,       UpperCAmelCase_							:      Tuple=18		,       UpperCAmelCase_							:      Optional[Any]=30		,       UpperCAmelCase_							:      str=400		,       UpperCAmelCase_							:      int=True		,       UpperCAmelCase_							:      Optional[int]=None		,       UpperCAmelCase_							:      Optional[Any]=True		,       )					->Optional[Any]:



														"""simple docstring"""



														snake_case_           =		size if size is not None else {"""height""": 18, """width""": 18}
														snake_case_           =		parent
														snake_case_           =		batch_size
														snake_case_           =		num_channels
														snake_case_           =		image_size
														snake_case_           =		min_resolution
														snake_case_           =		max_resolution
														snake_case_           =		do_resize
														snake_case_           =		size
														snake_case_           =		do_normalize



							def 		lowerCAmelCase       (				self							:      List[str]       )					->Optional[Any]:



														"""simple docstring"""



														return {
														    # here we create 2 clusters for the sake of simplicity
														    "clusters": np.asarray(
														        [
														            [0.8_866_443_634_033_203, 0.6_618_829_369_544_983, 0.3_891_746_401_786_804],
														            [-0.6_042_559_146_881_104, -0.02_295_008_860_528_469, 0.5_423_797_369_003_296],
														        ]       ),
														    "do_resize": self.do_resize,
														    "size": self.size,
														    "do_normalize": self.do_normalize,
														}





@require_torch
@require_vision
class      __A     (snake_case__						,		unittest.TestCase):





							'''simple docstring'''

							__lowercase:		List[Any]							      =    ImageGPTImageProcessor if is_vision_available() else None



							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->Optional[int]:



														"""simple docstring"""



														snake_case_           =		ImageGPTImageProcessingTester(self       )



							@property
							def 		lowerCAmelCase       (				self							:      Tuple       )					->List[Any]:



														"""simple docstring"""



														return self.image_processor_tester.prepare_image_processor_dict()



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		self.image_processing_class(**self.image_processor_dict       )
														self.assertTrue(hasattr(UpperCAmelCase_		,       """clusters"""       )       )
														self.assertTrue(hasattr(UpperCAmelCase_		,       """do_resize"""       )       )
														self.assertTrue(hasattr(UpperCAmelCase_		,       """size"""       )       )
														self.assertTrue(hasattr(UpperCAmelCase_		,       """do_normalize"""       )       )



							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->Optional[Any]:



														"""simple docstring"""



														snake_case_           =		self.image_processing_class.from_dict(self.image_processor_dict       )
														self.assertEqual(image_processor.size		,       {"""height""": 18, """width""": 18}       )

														snake_case_           =		self.image_processing_class.from_dict(self.image_processor_dict		,       size=42       )
														self.assertEqual(image_processor.size		,       {"""height""": 42, """width""": 42}       )



							def 		lowerCAmelCase       (				self							:      Any       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		self.image_processing_class(**self.image_processor_dict       )
														snake_case_           =		json.loads(image_processor.to_json_string()       )
														for key, value in self.image_processor_dict.items():
																					if key == "clusters":
																												self.assertTrue(np.array_equal(UpperCAmelCase_		,       obj[key]       )       )
																					else:
																												self.assertEqual(obj[key]		,       UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      Optional[int]       )					->Dict:



														"""simple docstring"""



														snake_case_           =		self.image_processing_class(**self.image_processor_dict       )

														with tempfile.TemporaryDirectory() as tmpdirname:
																					snake_case_           =		os.path.join(UpperCAmelCase_		,       """image_processor.json"""       )
																					image_processor_first.to_json_file(UpperCAmelCase_       )
																					snake_case_           =		self.image_processing_class.from_json_file(UpperCAmelCase_       ).to_dict()

														snake_case_           =		image_processor_first.to_dict()
														for key, value in image_processor_first.items():
																					if key == "clusters":
																												self.assertTrue(np.array_equal(UpperCAmelCase_		,       image_processor_second[key]       )       )
																					else:
																												self.assertEqual(image_processor_first[key]		,       UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		self.image_processing_class(**self.image_processor_dict       )

														with tempfile.TemporaryDirectory() as tmpdirname:
																					image_processor_first.save_pretrained(UpperCAmelCase_       )
																					snake_case_           =		self.image_processing_class.from_pretrained(UpperCAmelCase_       ).to_dict()

														snake_case_           =		image_processor_first.to_dict()
														for key, value in image_processor_first.items():
																					if key == "clusters":
																												self.assertTrue(np.array_equal(UpperCAmelCase_		,       image_processor_second[key]       )       )
																					else:
																												self.assertEqual(image_processor_first[key]		,       UpperCAmelCase_       )



							@unittest.skip("""ImageGPT requires clusters at initialization"""       )
							def 		lowerCAmelCase       (				self							:      List[Any]       )					->Tuple:



														"""simple docstring"""



														pass







def 						_a				(      )    ->				str:
							snake_case_           =		load_dataset("""hf-internal-testing/fixtures_image_utils"""				, split="""test"""				)

							snake_case_           =		Image.open(dataset[4]["""file"""]				)
							snake_case_           =		Image.open(dataset[5]["""file"""]				)

							snake_case_           =		[imagea, imagea]

							return images





@require_vision
@require_torch
class      __A     (unittest.TestCase):





							'''simple docstring'''

							@slow
							def 		lowerCAmelCase       (				self							:      Tuple       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		ImageGPTImageProcessor.from_pretrained("""openai/imagegpt-small"""       )

														snake_case_           =		prepare_images()

														# test non-batched
														snake_case_           =		image_processing(images[0]		,       return_tensors="""pt"""       )

														self.assertIsInstance(encoding.input_ids		,       torch.LongTensor       )
														self.assertEqual(encoding.input_ids.shape		,       (1, 1_024)       )

														snake_case_           =		[306, 191, 191]
														self.assertEqual(encoding.input_ids[0, :3].tolist()		,       UpperCAmelCase_       )

														# test batched
														snake_case_           =		image_processing(UpperCAmelCase_		,       return_tensors="""pt"""       )

														self.assertIsInstance(encoding.input_ids		,       torch.LongTensor       )
														self.assertEqual(encoding.input_ids.shape		,       (2, 1_024)       )

														snake_case_           =		[303, 13, 13]
														self.assertEqual(encoding.input_ids[1, -3:].tolist()		,       UpperCAmelCase_       )



