
import unittest

from transformers import ErnieMConfig, is_torch_available
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 (
     ErnieMForInformationExtraction,
     ErnieMForMultipleChoice,
     ErnieMForQuestionAnswering,
     ErnieMForSequenceClassification,
     ErnieMForTokenClassification,
     ErnieMModel,
 )
 from transformers.models.ernie_m.modeling_ernie_m import ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST







class  _lowerCamelCase			:

     def __init__(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_=13							,       SCREAMING_SNAKE_CASE_=7							,       SCREAMING_SNAKE_CASE_=True							,       SCREAMING_SNAKE_CASE_=True							,       SCREAMING_SNAKE_CASE_=True							,       SCREAMING_SNAKE_CASE_=99							,       SCREAMING_SNAKE_CASE_=32							,       SCREAMING_SNAKE_CASE_=5							,       SCREAMING_SNAKE_CASE_=4							,       SCREAMING_SNAKE_CASE_=37							,       SCREAMING_SNAKE_CASE_="gelu"							,       SCREAMING_SNAKE_CASE_=0.1							,       SCREAMING_SNAKE_CASE_=0.1							,       SCREAMING_SNAKE_CASE_=512							,       SCREAMING_SNAKE_CASE_=16							,       SCREAMING_SNAKE_CASE_=2							,       SCREAMING_SNAKE_CASE_=0.0_2							,       SCREAMING_SNAKE_CASE_=3							,       SCREAMING_SNAKE_CASE_=4							,       SCREAMING_SNAKE_CASE_=None							,       ):
            __snake_case						       =   parent
            __snake_case						       =   batch_size
            __snake_case						       =   seq_length
            __snake_case						       =   is_training
            __snake_case						       =   use_input_mask
            __snake_case						       =   use_labels
            __snake_case						       =   vocab_size
            __snake_case						       =   hidden_size
            __snake_case						       =   num_hidden_layers
            __snake_case						       =   num_attention_heads
            __snake_case						       =   intermediate_size
            __snake_case						       =   hidden_act
            __snake_case						       =   hidden_dropout_prob
            __snake_case						       =   attention_probs_dropout_prob
            __snake_case						       =   max_position_embeddings
            __snake_case						       =   type_vocab_size
            __snake_case						       =   type_sequence_label_size
            __snake_case						       =   initializer_range
            __snake_case						       =   num_labels
            __snake_case						       =   num_choices
            __snake_case						       =   scope

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   ids_tensor([self.batch_size, self.seq_length]							,       self.vocab_size    )

            __snake_case						       =   None
            if self.use_input_mask:
                   __snake_case						       =   random_attention_mask([self.batch_size, self.seq_length]    )

            __snake_case						       =   None
            __snake_case						       =   None
            __snake_case						       =   None
            if self.use_labels:
                   __snake_case						       =   ids_tensor([self.batch_size]							,       self.type_sequence_label_size    )
                   __snake_case						       =   ids_tensor([self.batch_size, self.seq_length]							,       self.num_labels    )
                   __snake_case						       =   ids_tensor([self.batch_size]							,       self.num_choices    )

            __snake_case						       =   self.get_config()

            return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   ids_tensor([self.batch_size, self.seq_length]							,       self.vocab_size    )

            __snake_case						       =   None
            if self.use_input_mask:
                   __snake_case						       =   random_attention_mask([self.batch_size, self.seq_length]    )
            __snake_case						       =   self.get_config()

            return config, input_ids, input_mask

     def 						__lowerCamelCase				(  self    ):
            return ErnieMConfig(
                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							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   ErnieMModel(config=SCREAMING_SNAKE_CASE_    )
            model.to(SCREAMING_SNAKE_CASE_    )
            model.eval()
            __snake_case						       =   model(SCREAMING_SNAKE_CASE_							,       return_dict=SCREAMING_SNAKE_CASE_    )
            self.parent.assertEqual(result.last_hidden_state.shape							,       (self.batch_size, self.seq_length, self.hidden_size)    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   ErnieMForQuestionAnswering(config=SCREAMING_SNAKE_CASE_    )
            model.to(SCREAMING_SNAKE_CASE_    )
            model.eval()
            __snake_case						       =   model(
                SCREAMING_SNAKE_CASE_							,       attention_mask=SCREAMING_SNAKE_CASE_							,       start_positions=SCREAMING_SNAKE_CASE_							,       end_positions=SCREAMING_SNAKE_CASE_							,       )
            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							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   ErnieMForInformationExtraction(config=SCREAMING_SNAKE_CASE_    )
            model.to(SCREAMING_SNAKE_CASE_    )
            model.eval()
            __snake_case						       =   torch.ones_like(SCREAMING_SNAKE_CASE_							,       dtype=torch.floataa    )
            __snake_case						       =   model(
                SCREAMING_SNAKE_CASE_							,       attention_mask=SCREAMING_SNAKE_CASE_							,       start_positions=SCREAMING_SNAKE_CASE_							,       end_positions=SCREAMING_SNAKE_CASE_							,       )
            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							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   self.num_labels
            __snake_case						       =   ErnieMForSequenceClassification(SCREAMING_SNAKE_CASE_    )
            model.to(SCREAMING_SNAKE_CASE_    )
            model.eval()
            __snake_case						       =   model(SCREAMING_SNAKE_CASE_							,       attention_mask=SCREAMING_SNAKE_CASE_							,       labels=SCREAMING_SNAKE_CASE_    )
            self.parent.assertEqual(result.logits.shape							,       (self.batch_size, self.num_labels)    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   self.num_labels
            __snake_case						       =   ErnieMForTokenClassification(config=SCREAMING_SNAKE_CASE_    )
            model.to(SCREAMING_SNAKE_CASE_    )
            model.eval()
            input_ids.to(SCREAMING_SNAKE_CASE_    )
            input_mask.to(SCREAMING_SNAKE_CASE_    )
            token_labels.to(SCREAMING_SNAKE_CASE_    )

            __snake_case						       =   model(SCREAMING_SNAKE_CASE_							,       attention_mask=SCREAMING_SNAKE_CASE_							,       labels=SCREAMING_SNAKE_CASE_    )

            self.parent.assertEqual(result.logits.shape							,       (self.batch_size, self.seq_length, self.num_labels)    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   self.num_choices
            __snake_case						       =   ErnieMForMultipleChoice(config=SCREAMING_SNAKE_CASE_    )
            model.to(SCREAMING_SNAKE_CASE_    )
            model.eval()
            __snake_case						       =   input_ids.unsqueeze(1    ).expand(-1							,       self.num_choices							,       -1    ).contiguous()
            __snake_case						       =   input_mask.unsqueeze(1    ).expand(-1							,       self.num_choices							,       -1    ).contiguous()
            __snake_case						       =   model(
                SCREAMING_SNAKE_CASE_							,       attention_mask=SCREAMING_SNAKE_CASE_							,       labels=SCREAMING_SNAKE_CASE_							,       )
            self.parent.assertEqual(result.logits.shape							,       (self.batch_size, self.num_choices)    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.prepare_config_and_inputs()
            (
                (
                __snake_case
            )       ,       (
                __snake_case
            )       ,       (
                __snake_case
            )       ,       (
                __snake_case
            )       ,       (
                __snake_case
            )       ,       (
                __snake_case
            )       ,       
            )						       =   config_and_inputs
            __snake_case						       =   {'input_ids': input_ids, 'attention_mask': input_mask}
            return config, inputs_dict







@require_torch
class  _lowerCamelCase			(lowerCamelCase							,					lowerCamelCase							,					unittest.TestCase					):
     lowercase__				  =			(
         (
             ErnieMModel,
             ErnieMForMultipleChoice,
             ErnieMForQuestionAnswering,
             ErnieMForSequenceClassification,
             ErnieMForTokenClassification,
         )
         if is_torch_available()
         else ()
     )
     lowercase__				  =			()
     lowercase__				  =			(
         {
             """feature-extraction""": ErnieMModel,
             """question-answering""": ErnieMForQuestionAnswering,
             """text-classification""": ErnieMForSequenceClassification,
             """token-classification""": ErnieMForTokenClassification,
             """zero-shot""": ErnieMForSequenceClassification,
         }
         if is_torch_available()
         else {}
     )
     lowercase__				  =			False

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ):
            if pipeline_test_casse_name == "QAPipelineTests":
                   return True

            return False

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   ErnieMModelTester(self    )
            __snake_case						       =   ConfigTester(self							,       config_class=SCREAMING_SNAKE_CASE_							,       hidden_size=37    )

     def 						__lowerCamelCase				(  self    ):
            self.config_tester.run_common_tests()

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            for type in ["absolute", "relative_key", "relative_key_query"]:
                   __snake_case						       =   type
                   self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_information_extraction(*SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE_    )

     @slow
     def 						__lowerCamelCase				(  self    ):
            for model_name in ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                   __snake_case						       =   ErnieMModel.from_pretrained(SCREAMING_SNAKE_CASE_    )
                   self.assertIsNotNone(SCREAMING_SNAKE_CASE_    )







@require_torch
class  _lowerCamelCase			(unittest.TestCase					):

     @slow
     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   ErnieMModel.from_pretrained('susnato/ernie-m-base_pytorch'    )
            model.eval()
            __snake_case						       =   torch.tensor([[0, 1, 2, 3, 4, 5]]    )
            __snake_case						       =   model(SCREAMING_SNAKE_CASE_    )[0]

            # TODO Replace vocab size
            __snake_case						       =   768

            __snake_case						       =   torch.Size((1, 6, hidden_size)    )
            self.assertEqual(output.shape							,       SCREAMING_SNAKE_CASE_    )

            __snake_case						       =   torch.tensor(
                [[[-0.0_0_1_2, 0.1_2_4_5, -0.0_2_1_4], [-0.0_7_4_2, 0.0_2_4_4, -0.0_7_7_1], [-0.0_3_3_3, 0.1_1_6_4, -0.1_5_5_4]]]    )

            self.assertTrue(torch.allclose(output[:, :3, :3]							,       SCREAMING_SNAKE_CASE_							,       atol=1E-3    )    )


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 center_crop, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_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_				:							List[str]       =    logging.get_logger(__name__)







class  _lowerCamelCase			(lowerCamelCase					):
     lowercase__				  =			["""pixel_values"""]

     def __init__(  self							,       SCREAMING_SNAKE_CASE_ = True							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = PIL.Image.NEAREST							,       SCREAMING_SNAKE_CASE_ = False							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = 1 / 255							,       SCREAMING_SNAKE_CASE_ = False							,       SCREAMING_SNAKE_CASE_ = True							,       SCREAMING_SNAKE_CASE_ = True							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = True							,       **SCREAMING_SNAKE_CASE_							,       ):
            super().__init__(**SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   size if size is not None else {'height': 346, 'width': 346}
            __snake_case						       =   get_size_dict(SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   crop_size if crop_size is not None else {'height': 289, 'width': 289}
            __snake_case						       =   get_size_dict(SCREAMING_SNAKE_CASE_							,       param_name='crop_size'    )

            __snake_case						       =   do_resize
            __snake_case						       =   size
            __snake_case						       =   resample
            __snake_case						       =   do_center_crop
            __snake_case						       =   crop_size
            __snake_case						       =   do_rescale
            __snake_case						       =   rescale_factor
            __snake_case						       =   rescale_offset
            __snake_case						       =   do_normalize
            __snake_case						       =   image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
            __snake_case						       =   image_std if image_std is not None else IMAGENET_STANDARD_STD
            __snake_case						       =   include_top

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_ = PIL.Image.NEAREST							,       SCREAMING_SNAKE_CASE_ = None							,       **SCREAMING_SNAKE_CASE_							,       ):
            __snake_case						       =   get_size_dict(SCREAMING_SNAKE_CASE_    )
            if "height" not in size or "width" not in size:
                   raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}'''    )
            return resize(
                SCREAMING_SNAKE_CASE_							,       size=(size['height'], size['width'])							,       resample=SCREAMING_SNAKE_CASE_							,       data_format=SCREAMING_SNAKE_CASE_							,       **SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_ = None							,       **SCREAMING_SNAKE_CASE_							,       ):
            __snake_case						       =   get_size_dict(SCREAMING_SNAKE_CASE_    )
            if "height" not in size or "width" not in size:
                   raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}'''    )
            return center_crop(SCREAMING_SNAKE_CASE_							,       size=(size['height'], size['width'])							,       data_format=SCREAMING_SNAKE_CASE_							,       **SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_ = True							,       SCREAMING_SNAKE_CASE_ = None							,       **SCREAMING_SNAKE_CASE_							,       ):
            if offset:
                   __snake_case						       =   (image - 1_2_7.5) * scale
                   if data_format is not None:
                          __snake_case						       =   to_channel_dimension_format(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    )
                   __snake_case						       =   rescaled_image.astype(np.floataa    )
            else:
                   __snake_case						       =   rescale(SCREAMING_SNAKE_CASE_							,       scale=SCREAMING_SNAKE_CASE_							,       data_format=SCREAMING_SNAKE_CASE_							,       **SCREAMING_SNAKE_CASE_    )
            return rescaled_image

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_ = None							,       **SCREAMING_SNAKE_CASE_							,       ):
            return normalize(SCREAMING_SNAKE_CASE_							,       mean=SCREAMING_SNAKE_CASE_							,       std=SCREAMING_SNAKE_CASE_							,       data_format=SCREAMING_SNAKE_CASE_							,       **SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_=None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = None							,       SCREAMING_SNAKE_CASE_ = ChannelDimension.FIRST							,       **SCREAMING_SNAKE_CASE_							,       ):
            __snake_case						       =   do_resize if do_resize is not None else self.do_resize
            __snake_case						       =   resample if resample is not None else self.resample
            __snake_case						       =   do_center_crop if do_center_crop is not None else self.do_center_crop
            __snake_case						       =   do_rescale if do_rescale is not None else self.do_rescale
            __snake_case						       =   rescale_factor if rescale_factor is not None else self.rescale_factor
            __snake_case						       =   rescale_offset if rescale_offset is not None else self.rescale_offset
            __snake_case						       =   do_normalize if do_normalize is not None else self.do_normalize
            __snake_case						       =   image_mean if image_mean is not None else self.image_mean
            __snake_case						       =   image_std if image_std is not None else self.image_std
            __snake_case						       =   include_top if include_top is not None else self.include_top

            __snake_case						       =   size if size is not None else self.size
            __snake_case						       =   get_size_dict(SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   crop_size if crop_size is not None else self.crop_size
            __snake_case						       =   get_size_dict(SCREAMING_SNAKE_CASE_							,       param_name='crop_size'    )

            __snake_case						       =   make_list_of_images(SCREAMING_SNAKE_CASE_    )

            if not valid_images(SCREAMING_SNAKE_CASE_    ):
                   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_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.'    )

            # All transformations expect numpy arrays.
            __snake_case						       =   [to_numpy_array(SCREAMING_SNAKE_CASE_    ) for image in images]

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

            if do_center_crop:
                   __snake_case						       =   [self.center_crop(image=SCREAMING_SNAKE_CASE_							,       size=SCREAMING_SNAKE_CASE_    ) for image in images]

            if do_rescale:
                   __snake_case						       =   [self.rescale(image=SCREAMING_SNAKE_CASE_							,       scale=SCREAMING_SNAKE_CASE_							,       offset=SCREAMING_SNAKE_CASE_    ) for image in images]

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

            if include_top:
                   __snake_case						       =   [self.normalize(image=SCREAMING_SNAKE_CASE_							,       mean=[0, 0, 0]							,       std=SCREAMING_SNAKE_CASE_    ) for image in images]

            __snake_case						       =   [to_channel_dimension_format(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    ) for image in images]

            __snake_case						       =   {'pixel_values': images}
            return BatchFeature(data=SCREAMING_SNAKE_CASE_							,       tensor_type=SCREAMING_SNAKE_CASE_    )
