'''simple docstring'''






import unittest

from transformers import LiltConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import (
         LiltForQuestionAnswering,
         LiltForSequenceClassification,
         LiltForTokenClassification,
         LiltModel,
     )
     from transformers.models.lilt.modeling_lilt import LILT_PRETRAINED_MODEL_ARCHIVE_LIST





class     A__							:





   """simple docstring"""





   def __init__( self     :		Any						,     lowerCAmelCase__     :		List[Any]						,     lowerCAmelCase__     :		List[str]=1_3						,     lowerCAmelCase__     :		int=7						,     lowerCAmelCase__     :		Any=True						,     lowerCAmelCase__     :		str=True						,     lowerCAmelCase__     :		List[Any]=True						,     lowerCAmelCase__     :		List[Any]=True						,     lowerCAmelCase__     :		Dict=9_9						,     lowerCAmelCase__     :		Union[str, Any]=2_4						,     lowerCAmelCase__     :		int=2						,     lowerCAmelCase__     :		List[str]=6						,     lowerCAmelCase__     :		Any=3_7						,     lowerCAmelCase__     :		Dict="gelu"						,     lowerCAmelCase__     :		List[str]=0.1						,     lowerCAmelCase__     :		Dict=0.1						,     lowerCAmelCase__     :		Union[str, Any]=5_1_2						,     lowerCAmelCase__     :		List[str]=1_6						,     lowerCAmelCase__     :		Any=2						,     lowerCAmelCase__     :		Any=0.02						,     lowerCAmelCase__     :		List[Any]=3						,     lowerCAmelCase__     :		Optional[int]=None						,     lowerCAmelCase__     :		str=1_0_0_0						,     )       ->    Optional[int]:







      """simple docstring"""




      _UpperCAmelCase							:	List[str]							=   parent
      _UpperCAmelCase							:	Optional[Any]							=   batch_size
      _UpperCAmelCase							:	Optional[Any]							=   seq_length
      _UpperCAmelCase							:	List[Any]							=   is_training
      _UpperCAmelCase							:	Optional[int]							=   use_input_mask
      _UpperCAmelCase							:	Optional[Any]							=   use_token_type_ids
      _UpperCAmelCase							:	int							=   use_labels
      _UpperCAmelCase							:	List[Any]							=   vocab_size
      _UpperCAmelCase							:	List[str]							=   hidden_size
      _UpperCAmelCase							:	List[Any]							=   num_hidden_layers
      _UpperCAmelCase							:	List[str]							=   num_attention_heads
      _UpperCAmelCase							:	Tuple							=   intermediate_size
      _UpperCAmelCase							:	Tuple							=   hidden_act
      _UpperCAmelCase							:	int							=   hidden_dropout_prob
      _UpperCAmelCase							:	str							=   attention_probs_dropout_prob
      _UpperCAmelCase							:	List[Any]							=   max_position_embeddings
      _UpperCAmelCase							:	Union[str, Any]							=   type_vocab_size
      _UpperCAmelCase							:	List[str]							=   type_sequence_label_size
      _UpperCAmelCase							:	Any							=   initializer_range
      _UpperCAmelCase							:	Optional[Any]							=   num_labels
      _UpperCAmelCase							:	Tuple							=   scope
      _UpperCAmelCase							:	Optional[int]							=   range_bbox




   def 			_lowerCAmelCase		( self     :		List[str]			)       ->    int:







      """simple docstring"""




      _UpperCAmelCase							:	Tuple							=   ids_tensor([self.batch_size, self.seq_length]						,     self.vocab_size			)

      _UpperCAmelCase							:	Dict							=   ids_tensor([self.batch_size, self.seq_length, 4]						,     self.range_bbox			)
      # Ensure that bbox is legal
      for i in range(bbox.shape[0]			):
         for j in range(bbox.shape[1]			):
            if bbox[i, j, 3] < bbox[i, j, 1]:
               _UpperCAmelCase							:	Optional[int]							=   bbox[i, j, 3]
               _UpperCAmelCase							:	Optional[int]							=   bbox[i, j, 1]
               _UpperCAmelCase							:	str							=   t
            if bbox[i, j, 2] < bbox[i, j, 0]:
               _UpperCAmelCase							:	List[str]							=   bbox[i, j, 2]
               _UpperCAmelCase							:	Optional[int]							=   bbox[i, j, 0]
               _UpperCAmelCase							:	List[str]							=   t

      _UpperCAmelCase							:	Tuple							=   None
      if self.use_input_mask:
         _UpperCAmelCase							:	List[Any]							=   ids_tensor([self.batch_size, self.seq_length]						,     vocab_size=2			)

      _UpperCAmelCase							:	Union[str, Any]							=   None
      if self.use_token_type_ids:
         _UpperCAmelCase							:	Optional[int]							=   ids_tensor([self.batch_size, self.seq_length]						,     self.type_vocab_size			)

      _UpperCAmelCase							:	List[str]							=   None
      _UpperCAmelCase							:	List[str]							=   None
      if self.use_labels:
         _UpperCAmelCase							:	int							=   ids_tensor([self.batch_size]						,     self.type_sequence_label_size			)
         _UpperCAmelCase							:	Dict							=   ids_tensor([self.batch_size, self.seq_length]						,     self.num_labels			)

      _UpperCAmelCase							:	Any							=   self.get_config()

      return config, input_ids, bbox, token_type_ids, input_mask, sequence_labels, token_labels




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







      """simple docstring"""




      return LiltConfig(
          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_size=self.intermediate_size						,     hidden_act=self.hidden_act						,     hidden_dropout_prob=self.hidden_dropout_prob						,     attention_probs_dropout_prob=self.attention_probs_dropout_prob						,     max_position_embeddings=self.max_position_embeddings						,     type_vocab_size=self.type_vocab_size						,     initializer_range=self.initializer_range						,     )




   def 			_lowerCAmelCase		( self     :		Optional[int]						,     lowerCAmelCase__     :		Optional[Any]						,     lowerCAmelCase__     :		Optional[Any]						,     lowerCAmelCase__     :		str						,     lowerCAmelCase__     :		Optional[Any]						,     lowerCAmelCase__     :		int						,     lowerCAmelCase__     :		Optional[Any]						,     lowerCAmelCase__     :		int						,     )       ->    List[str]:







      """simple docstring"""




      _UpperCAmelCase							:	Tuple							=   LiltModel(config=lowercase_			)
      model.to(lowercase_			)
      model.eval()
      _UpperCAmelCase							:	List[Any]							=   model(lowercase_						,     bbox=lowercase_						,     attention_mask=lowercase_						,     token_type_ids=lowercase_			)
      _UpperCAmelCase							:	List[Any]							=   model(lowercase_						,     bbox=lowercase_						,     token_type_ids=lowercase_			)
      _UpperCAmelCase							:	int							=   model(lowercase_						,     bbox=lowercase_			)

      self.parent.assertEqual(result.last_hidden_state.shape						,     (self.batch_size, self.seq_length, self.hidden_size)			)
      self.parent.assertEqual(result.pooler_output.shape						,     (self.batch_size, self.hidden_size)			)




   def 			_lowerCAmelCase		( self     :		int						,     lowerCAmelCase__     :		Union[str, Any]						,     lowerCAmelCase__     :		Union[str, Any]						,     lowerCAmelCase__     :		Union[str, Any]						,     lowerCAmelCase__     :		Optional[Any]						,     lowerCAmelCase__     :		Union[str, Any]						,     lowerCAmelCase__     :		List[Any]						,     lowerCAmelCase__     :		int						,     )       ->    Optional[Any]:







      """simple docstring"""




      _UpperCAmelCase							:	Optional[Any]							=   self.num_labels
      _UpperCAmelCase							:	Optional[Any]							=   LiltForTokenClassification(config=lowercase_			)
      model.to(lowercase_			)
      model.eval()
      _UpperCAmelCase							:	Tuple							=   model(
          lowercase_						,     bbox=lowercase_						,     attention_mask=lowercase_						,     token_type_ids=lowercase_						,     labels=lowercase_			)
      self.parent.assertEqual(result.logits.shape						,     (self.batch_size, self.seq_length, self.num_labels)			)




   def 			_lowerCAmelCase		( self     :		Tuple						,     lowerCAmelCase__     :		str						,     lowerCAmelCase__     :		Union[str, Any]						,     lowerCAmelCase__     :		Any						,     lowerCAmelCase__     :		Dict						,     lowerCAmelCase__     :		List[str]						,     lowerCAmelCase__     :		List[Any]						,     lowerCAmelCase__     :		str						,     )       ->    Optional[int]:







      """simple docstring"""




      _UpperCAmelCase							:	Union[str, Any]							=   LiltForQuestionAnswering(config=lowercase_			)
      model.to(lowercase_			)
      model.eval()
      _UpperCAmelCase							:	Optional[int]							=   model(
          lowercase_						,     bbox=lowercase_						,     attention_mask=lowercase_						,     token_type_ids=lowercase_						,     start_positions=lowercase_						,     end_positions=lowercase_						,     )
      self.parent.assertEqual(result.start_logits.shape						,     (self.batch_size, self.seq_length)			)
      self.parent.assertEqual(result.end_logits.shape						,     (self.batch_size, self.seq_length)			)




   def 			_lowerCAmelCase		( self     :		Tuple			)       ->    List[Any]:







      """simple docstring"""




      _UpperCAmelCase							:	str							=   self.prepare_config_and_inputs()
      (
          _UpperCAmelCase			
      )							:	List[str]							=   config_and_inputs
      _UpperCAmelCase							:	str							=   {
          '''input_ids''': input_ids,
          '''bbox''': bbox,
          '''token_type_ids''': token_type_ids,
          '''attention_mask''': input_mask,
      }
      return config, inputs_dict





@require_torch
class     A__							(       UpperCAmelCase__					,		UpperCAmelCase__					,		UpperCAmelCase__					,		unittest.TestCase   ):





   """simple docstring"""





   UpperCamelCase_       :						Dict    				=     (
       (
           LiltModel,
           LiltForSequenceClassification,
           LiltForTokenClassification,
           LiltForQuestionAnswering,
       )
       if is_torch_available()
       else ()
   )
   UpperCamelCase_       :						int    				=     (
       {
           '''feature-extraction''': LiltModel,
           '''question-answering''': LiltForQuestionAnswering,
           '''text-classification''': LiltForSequenceClassification,
           '''token-classification''': LiltForTokenClassification,
           '''zero-shot''': LiltForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   UpperCamelCase_       :						str    				=     False
   UpperCamelCase_       :						Optional[Any]    				=     False




   def 			_lowerCAmelCase		( self     :		Any						,     lowerCAmelCase__     :		List[str]						,     lowerCAmelCase__     :		Optional[int]						,     lowerCAmelCase__     :		Optional[int]						,     lowerCAmelCase__     :		str						,     lowerCAmelCase__     :		str			)       ->    Tuple:







      """simple docstring"""




      return True




   def 			_lowerCAmelCase		( self     :		Tuple			)       ->    Optional[int]:







      """simple docstring"""




      _UpperCAmelCase							:	Dict							=   LiltModelTester(self			)
      _UpperCAmelCase							:	Optional[int]							=   ConfigTester(self						,     config_class=lowercase_						,     hidden_size=3_7			)




   def 			_lowerCAmelCase		( self     :		Union[str, Any]			)       ->    Tuple:







      """simple docstring"""




      self.config_tester.run_common_tests()




   def 			_lowerCAmelCase		( self     :		List[str]			)       ->    Optional[int]:







      """simple docstring"""




      _UpperCAmelCase							:	Union[str, Any]							=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*lowercase_			)




   def 			_lowerCAmelCase		( self     :		Tuple			)       ->    Tuple:







      """simple docstring"""




      _UpperCAmelCase							:	Tuple							=   self.model_tester.prepare_config_and_inputs()
      for type in ["absolute", "relative_key", "relative_key_query"]:
         _UpperCAmelCase							:	Dict							=   type
         self.model_tester.create_and_check_model(*lowercase_			)




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







      """simple docstring"""




      _UpperCAmelCase							:	Optional[Any]							=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_token_classification(*lowercase_			)




   def 			_lowerCAmelCase		( self     :		Tuple			)       ->    Any:







      """simple docstring"""




      _UpperCAmelCase							:	List[str]							=   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_question_answering(*lowercase_			)




   @slow
   def 			_lowerCAmelCase		( self     :		Optional[int]			)       ->    Any:







      """simple docstring"""




      for model_name in LILT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         _UpperCAmelCase							:	Optional[int]							=   LiltModel.from_pretrained(lowercase_			)
         self.assertIsNotNone(lowercase_			)





@require_torch
@slow
class     A__							(       unittest.TestCase   ):





   """simple docstring"""





   def 			_lowerCAmelCase		( self     :		Optional[int]			)       ->    Tuple:







      """simple docstring"""




      _UpperCAmelCase							:	List[str]							=   LiltModel.from_pretrained("SCUT-DLVCLab/lilt-roberta-en-base"			).to(lowercase_			)

      _UpperCAmelCase							:	str							=   torch.tensor([[1, 2]]						,     device=lowercase_			)
      _UpperCAmelCase							:	Optional[int]							=   torch.tensor([[[1, 2, 3, 4], [5, 6, 7, 8]]]						,     device=lowercase_			)

      # forward pass
      with torch.no_grad():
         _UpperCAmelCase							:	Dict							=   model(input_ids=lowercase_						,     bbox=lowercase_			)

      _UpperCAmelCase							:	str							=   torch.Size([1, 2, 7_6_8]			)
      _UpperCAmelCase							:	Dict							=   torch.tensor(
          [[-0.0653, 0.0950, -0.0061], [-0.0545, 0.0926, -0.0324]]						,     device=lowercase_						,     )

      self.assertTrue(outputs.last_hidden_state.shape						,     lowercase_			)
      self.assertTrue(torch.allclose(outputs.last_hidden_state[0, :, :3]						,     lowercase_						,     atol=1e-3			)			)







"""simple docstring"""






from typing import Dict, List, Optional, Union

import numpy as np

from transformers.utils import is_vision_available
from transformers.utils.generic import TensorType

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import logging


if is_vision_available():
  import PIL

UpperCAmelCase_   : int   			= logging.get_logger(__name__)



def 					_A			(__a							) ->       List[List[ImageInput]]:
    """simple docstring"""






    if isinstance(__a    ,				(list, tuple)							) and isinstance(videos[0]    ,				(list, tuple)							) and is_valid_image(videos[0][0]							):
        return videos

    elif isinstance(__a    ,				(list, tuple)							) and is_valid_image(videos[0]							):
        return [videos]

    elif is_valid_image(__a							):
        return [[videos]]

    raise ValueError(f'Could not make batched video from {videos}'							)





class 							lowerCAmelCase__				(			UpperCAmelCase__ ):






      '''simple docstring'''

      __UpperCamelCase	 =  ["pixel_values"]
      def __init__(						self     :  Dict						,	lowercase_     :  bool = True						,	lowercase_     :  Dict[str, int] = None						,	lowercase_     :  PILImageResampling = PILImageResampling.BILINEAR						,	lowercase_     :  bool = True						,	lowercase_     :  Dict[str, int] = None						,	lowercase_     :  bool = True						,	lowercase_     :  Union[int, float] = 1 / 255						,	lowercase_     :  bool = True						,	lowercase_     :  bool = True						,	lowercase_     :  Optional[Union[float, List[float]]] = None						,	lowercase_     :  Optional[Union[float, List[float]]] = None						,	**lowercase_     :  Dict						,	):




          '''simple docstring'''


          super().__init__(**lowercase_)
          SCREAMING_SNAKE_CASE_      :  str    						=		size if size is not None else {'''shortest_edge''': 256}
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		get_size_dict(lowercase_						,	default_to_square=lowercase_)
          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		crop_size if crop_size is not None else {'''height''': 224, '''width''': 224}
          SCREAMING_SNAKE_CASE_      :  Dict    						=		get_size_dict(lowercase_						,	param_name='''crop_size''')

          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		do_resize
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		size
          SCREAMING_SNAKE_CASE_      :  Tuple    						=		do_center_crop
          SCREAMING_SNAKE_CASE_      :  Dict    						=		crop_size
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		resample
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		do_rescale
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		rescale_factor
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		offset
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		do_normalize
          SCREAMING_SNAKE_CASE_      :  Tuple    						=		image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		image_std if image_std is not None else IMAGENET_STANDARD_STD
      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]						,	lowercase_     :  np.ndarray						,	lowercase_     :  Dict[str, int]						,	lowercase_     :  PILImageResampling = PILImageResampling.BILINEAR						,	lowercase_     :  Optional[Union[str, ChannelDimension]] = None						,	**lowercase_     :  Any						,	):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Tuple    						=		get_size_dict(lowercase_						,	default_to_square=lowercase_)
          if "shortest_edge" in size:
              SCREAMING_SNAKE_CASE_      :  List[Any]    						=		get_resize_output_image_size(lowercase_						,	size['''shortest_edge''']						,	default_to_square=lowercase_)
          elif "height" in size and "width" in size:
              SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		(size['''height'''], size['''width'''])
          else:
              raise ValueError(F'Size must have \'height\' and \'width\' or \'shortest_edge\' as keys. Got {size.keys()}')
          return resize(lowercase_						,	size=lowercase_						,	resample=lowercase_						,	data_format=lowercase_						,	**lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  Any						,	lowercase_     :  np.ndarray						,	lowercase_     :  Dict[str, int]						,	lowercase_     :  Optional[Union[str, ChannelDimension]] = None						,	**lowercase_     :  List[Any]						,	):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[str]    						=		get_size_dict(lowercase_)
          if "height" not in size or "width" not in size:
              raise ValueError(F'Size must have \'height\' and \'width\' as keys. Got {size.keys()}')
          return center_crop(lowercase_						,	size=(size['''height'''], size['''width'''])						,	data_format=lowercase_						,	**lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]						,	lowercase_     :  np.ndarray						,	lowercase_     :  Union[int, float]						,	lowercase_     :  bool = True						,	lowercase_     :  Optional[Union[str, ChannelDimension]] = None						,	**lowercase_     :  Optional[int]						,	):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		image.astype(np.floataa)
          if offset:
              SCREAMING_SNAKE_CASE_      :  Tuple    						=		image - (scale / 2)
          return rescale(lowercase_						,	scale=lowercase_						,	data_format=lowercase_						,	**lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]						,	lowercase_     :  np.ndarray						,	lowercase_     :  Union[float, List[float]]						,	lowercase_     :  Union[float, List[float]]						,	lowercase_     :  Optional[Union[str, ChannelDimension]] = None						,	**lowercase_     :  List[str]						,	):




          '''simple docstring'''


          return normalize(lowercase_						,	mean=lowercase_						,	std=lowercase_						,	data_format=lowercase_						,	**lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  List[str]						,	lowercase_     :  ImageInput						,	lowercase_     :  bool = None						,	lowercase_     :  Dict[str, int] = None						,	lowercase_     :  PILImageResampling = None						,	lowercase_     :  bool = None						,	lowercase_     :  Dict[str, int] = None						,	lowercase_     :  bool = None						,	lowercase_     :  float = None						,	lowercase_     :  bool = None						,	lowercase_     :  bool = None						,	lowercase_     :  Optional[Union[float, List[float]]] = None						,	lowercase_     :  Optional[Union[float, List[float]]] = None						,	lowercase_     :  Optional[ChannelDimension] = ChannelDimension.FIRST						,	):




          '''simple docstring'''


          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_center_crop and crop_size is None:
              raise ValueError('''Crop size must be specified if do_center_crop 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.''')

          if offset and not do_rescale:
              raise ValueError('''For offset, do_rescale must also be set to True.''')

          # All transformations expect numpy arrays.
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		to_numpy_array(lowercase_)

          if do_resize:
              SCREAMING_SNAKE_CASE_      :  List[Any]    						=		self.resize(image=lowercase_						,	size=lowercase_						,	resample=lowercase_)

          if do_center_crop:
              SCREAMING_SNAKE_CASE_      :  Dict    						=		self.center_crop(lowercase_						,	size=lowercase_)

          if do_rescale:
              SCREAMING_SNAKE_CASE_      :  int    						=		self.rescale(image=lowercase_						,	scale=lowercase_						,	offset=lowercase_)

          if do_normalize:
              SCREAMING_SNAKE_CASE_      :  Dict    						=		self.normalize(image=lowercase_						,	mean=lowercase_						,	std=lowercase_)

          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		to_channel_dimension_format(lowercase_						,	lowercase_)
          return image



      def _SCREAMING_SNAKE_CASE (						self     :  Dict						,	lowercase_     :  ImageInput						,	lowercase_     :  bool = None						,	lowercase_     :  Dict[str, int] = None						,	lowercase_     :  PILImageResampling = None						,	lowercase_     :  bool = None						,	lowercase_     :  Dict[str, int] = None						,	lowercase_     :  bool = None						,	lowercase_     :  float = None						,	lowercase_     :  bool = None						,	lowercase_     :  bool = None						,	lowercase_     :  Optional[Union[float, List[float]]] = None						,	lowercase_     :  Optional[Union[float, List[float]]] = None						,	lowercase_     :  Optional[Union[str, TensorType]] = None						,	lowercase_     :  ChannelDimension = ChannelDimension.FIRST						,	**lowercase_     :  Optional[Any]						,	):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		do_resize if do_resize is not None else self.do_resize
          SCREAMING_SNAKE_CASE_      :  int    						=		resample if resample is not None else self.resample
          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		do_center_crop if do_center_crop is not None else self.do_center_crop
          SCREAMING_SNAKE_CASE_      :  Dict    						=		do_rescale if do_rescale is not None else self.do_rescale
          SCREAMING_SNAKE_CASE_      :  Dict    						=		rescale_factor if rescale_factor is not None else self.rescale_factor
          SCREAMING_SNAKE_CASE_      :  Dict    						=		offset if offset is not None else self.offset
          SCREAMING_SNAKE_CASE_      :  str    						=		do_normalize if do_normalize is not None else self.do_normalize
          SCREAMING_SNAKE_CASE_      :  Dict    						=		image_mean if image_mean is not None else self.image_mean
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		image_std if image_std is not None else self.image_std

          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		size if size is not None else self.size
          SCREAMING_SNAKE_CASE_      :  Tuple    						=		get_size_dict(lowercase_						,	default_to_square=lowercase_)
          SCREAMING_SNAKE_CASE_      :  Any    						=		crop_size if crop_size is not None else self.crop_size
          SCREAMING_SNAKE_CASE_      :  Dict    						=		get_size_dict(lowercase_						,	param_name='''crop_size''')

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

          SCREAMING_SNAKE_CASE_      :  Tuple    						=		make_batched(lowercase_)

          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		[
              [
                  self._preprocess_image(
                      image=lowercase_						,	do_resize=lowercase_						,	size=lowercase_						,	resample=lowercase_						,	do_center_crop=lowercase_						,	crop_size=lowercase_						,	do_rescale=lowercase_						,	rescale_factor=lowercase_						,	offset=lowercase_						,	do_normalize=lowercase_						,	image_mean=lowercase_						,	image_std=lowercase_						,	data_format=lowercase_						,	)
                  for img in video
              ]
              for video in videos
          ]

          SCREAMING_SNAKE_CASE_      :  int    						=		{'''pixel_values''': videos}
          return BatchFeature(data=lowercase_						,	tensor_type=lowercase_)


