




"""simple docstring"""




from typing import List, Optional, Union

import numpy as np
import PIL.Image

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import rescale, resize, to_channel_dimension_format
from ...image_utils import (
    ChannelDimension,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


lowerCAmelCase							:    Union[str, Any]  							=							logging.get_logger(__name__)






class 					__magic_name__							( UpperCAmelCase__       ):






				'''simple docstring'''
				__UpperCamelCase    						=		["pixel_values"]





				def __init__( self	,				_a = True	,				_a = 32	,				_a=PILImageResampling.BILINEAR	,				_a = True	,				**_a	,				):





							"""simple docstring"""
							lowerCamelCase       =      do_resize
							lowerCamelCase       =      do_rescale
							lowerCamelCase       =      size_divisor
							lowerCamelCase       =      resample
							super().__init__(**_a				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a	,				_a	,				_a = None	,				**_a				):





							"""simple docstring"""
							lowerCamelCase   ,     lowerCamelCase       =      get_image_size(_a				)
							# Rounds the height and width down to the closest multiple of size_divisor
							lowerCamelCase       =      height // size_divisor * size_divisor
							lowerCamelCase       =      width // size_divisor * size_divisor
							lowerCamelCase       =      resize(_a	,				(new_h, new_w)	,				resample=_a	,				data_format=_a	,				**_a				)
							return image





				def      _lowerCAmelCase       ( self	,				_a	,				_a	,				_a = None	,				**_a				):





							"""simple docstring"""
							return rescale(image=_a	,				scale=_a	,				data_format=_a	,				**_a				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a = None	,				_a = None	,				_a=None	,				_a = None	,				_a = None	,				_a = ChannelDimension.FIRST	,				**_a	,				):





							"""simple docstring"""
							lowerCamelCase       =      do_resize if do_resize is not None else self.do_resize
							lowerCamelCase       =      do_rescale if do_rescale is not None else self.do_rescale
							lowerCamelCase       =      size_divisor if size_divisor is not None else self.size_divisor
							lowerCamelCase       =      resample if resample is not None else self.resample

							if do_resize and size_divisor is None:
										raise ValueError("""size_divisor is required for resizing"""				)

							lowerCamelCase       =      make_list_of_images(_a				)

							if not valid_images(_a				):
										raise ValueError("""Invalid image(s)"""				)

							# All transformations expect numpy arrays.
							lowerCamelCase       =      [to_numpy_array(_a				) for img in images]

							if do_resize:
										lowerCamelCase       =      [self.resize(_a	,				size_divisor=_a	,				resample=_a				) for image in images]

							if do_rescale:
										lowerCamelCase       =      [self.rescale(_a	,				scale=1 / 255				) for image in images]

							lowerCamelCase       =      [to_channel_dimension_format(_a	,				_a				) for image in images]

							lowerCamelCase       =      {"""pixel_values""": images}
							return BatchFeature(data=_a	,				tensor_type=_a				)









"""simple docstring"""




from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCAmelCase							:    List[str]  							=							{
    """configuration_autoformer""": [
        """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """AutoformerConfig""",
    ],
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase							:    Tuple  							=							[
					    """AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """AutoformerForPrediction""",
					    """AutoformerModel""",
					    """AutoformerPreTrainedModel""",
					]


if TYPE_CHECKING:
					from .configuration_autoformer import (
					    AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    AutoformerConfig,
					)

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_autoformer import (
										    AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    AutoformerForPrediction,
										    AutoformerModel,
										    AutoformerPreTrainedModel,
										)

else:
					import sys

					lowerCAmelCase							:    str  							=							_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



