





from typing import Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format
from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_images
from ...utils import TensorType, logging


_UpperCamelCase				=       logging.get_logger(__name__)




class  _lowerCamelCase       (			__SCREAMING_SNAKE_CASE			):



      """simple docstring"""






      UpperCAmelCase_  :					List[str]      			=["pixel_values"]







      def __init__(       self ,  UpperCAmelCase = True ,  UpperCAmelCase = 1 / 255 ,  UpperCAmelCase = True ,  UpperCAmelCase = 8 ,  **UpperCAmelCase ,  )				->      None:






        '''simple docstring'''






        super().__init__(**UpperCAmelCase_      )

        __snake_case      : Dict						=				do_rescale
        __snake_case      : Any						=				rescale_factor
        __snake_case      : List[str]						=				do_pad
        __snake_case      : List[Any]						=				pad_size







      def   UpperCAmelCase						(       self ,  UpperCAmelCase ,  UpperCAmelCase ,  UpperCAmelCase = None ,  **UpperCAmelCase      )				->      np.ndarray:






        '''simple docstring'''






        return rescale(UpperCAmelCase_ ,  scale=UpperCAmelCase_ ,  data_format=UpperCAmelCase_ ,  **UpperCAmelCase_      )







      def   UpperCAmelCase						(       self ,  UpperCAmelCase ,  UpperCAmelCase ,  UpperCAmelCase = None      )				->      str:






        '''simple docstring'''






        __snake_case      : Tuple						=				get_image_size(UpperCAmelCase_      )
        __snake_case      : Any						=				(old_height // size + 1) * size - old_height
        __snake_case      : Optional[int]						=				(old_width // size + 1) * size - old_width

        return pad(UpperCAmelCase_ ,  ((0, pad_height), (0, pad_width)) ,  mode="symmetric" ,  data_format=UpperCAmelCase_      )







      def   UpperCAmelCase						(       self ,  UpperCAmelCase ,  UpperCAmelCase = None ,  UpperCAmelCase = None ,  UpperCAmelCase = None ,  UpperCAmelCase = None ,  UpperCAmelCase = None ,  UpperCAmelCase = ChannelDimension.FIRST ,  **UpperCAmelCase ,  )				->      Any:






        '''simple docstring'''






        __snake_case      : Optional[int]						=				do_rescale if do_rescale is not None else self.do_rescale
        __snake_case      : Dict						=				rescale_factor if rescale_factor is not None else self.rescale_factor
        __snake_case      : int						=				do_pad if do_pad is not None else self.do_pad
        __snake_case      : Dict						=				pad_size if pad_size is not None else self.pad_size

        __snake_case      : Any						=				make_list_of_images(UpperCAmelCase_      )

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

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

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

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

        if do_pad:
          __snake_case      : Tuple						=				[self.pad(UpperCAmelCase_ ,  size=UpperCAmelCase_      ) for image in images]

        __snake_case      : Tuple						=				[to_channel_dimension_format(UpperCAmelCase_ ,  UpperCAmelCase_      ) for image in images]

        __snake_case      : Union[str, Any]						=				{"pixel_values": images}
        return BatchFeature(data=UpperCAmelCase_ ,  tensor_type=UpperCAmelCase_      )








from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A									=				{
    "configuration_distilbert": [
        "DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "DistilBertConfig",
        "DistilBertOnnxConfig",
    ],
    "tokenization_distilbert": ["DistilBertTokenizer"],
}

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A									=				["DistilBertTokenizerFast"]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A									=				[
         "DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
         "DistilBertForMaskedLM",
         "DistilBertForMultipleChoice",
         "DistilBertForQuestionAnswering",
         "DistilBertForSequenceClassification",
         "DistilBertForTokenClassification",
         "DistilBertModel",
         "DistilBertPreTrainedModel",
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A									=				[
         "TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
         "TFDistilBertForMaskedLM",
         "TFDistilBertForMultipleChoice",
         "TFDistilBertForQuestionAnswering",
         "TFDistilBertForSequenceClassification",
         "TFDistilBertForTokenClassification",
         "TFDistilBertMainLayer",
         "TFDistilBertModel",
         "TFDistilBertPreTrainedModel",
     ]

try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A									=				[
         "FlaxDistilBertForMaskedLM",
         "FlaxDistilBertForMultipleChoice",
         "FlaxDistilBertForQuestionAnswering",
         "FlaxDistilBertForSequenceClassification",
         "FlaxDistilBertForTokenClassification",
         "FlaxDistilBertModel",
         "FlaxDistilBertPreTrainedModel",
     ]


if TYPE_CHECKING:
     from .configuration_distilbert import (
         DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
         DistilBertConfig,
         DistilBertOnnxConfig,
     )
     from .tokenization_distilbert import DistilBertTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_distilbert_fast import DistilBertTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_distilbert import (
              DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
              DistilBertForMaskedLM,
              DistilBertForMultipleChoice,
              DistilBertForQuestionAnswering,
              DistilBertForSequenceClassification,
              DistilBertForTokenClassification,
              DistilBertModel,
              DistilBertPreTrainedModel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_distilbert import (
              TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFDistilBertForMaskedLM,
              TFDistilBertForMultipleChoice,
              TFDistilBertForQuestionAnswering,
              TFDistilBertForSequenceClassification,
              TFDistilBertForTokenClassification,
              TFDistilBertMainLayer,
              TFDistilBertModel,
              TFDistilBertPreTrainedModel,
          )

     try:
          if not is_flax_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_flax_distilbert import (
              FlaxDistilBertForMaskedLM,
              FlaxDistilBertForMultipleChoice,
              FlaxDistilBertForQuestionAnswering,
              FlaxDistilBertForSequenceClassification,
              FlaxDistilBertForTokenClassification,
              FlaxDistilBertModel,
              FlaxDistilBertPreTrainedModel,
          )

else:
     import sys

     __A									=				_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)

