from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowerCAmelCase__  	=      {
    "configuration_imagegpt": ["IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ImageGPTConfig", "ImageGPTOnnxConfig"]
}

try:
						if not is_vision_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase__  	=      ["ImageGPTFeatureExtractor"]
						lowerCAmelCase__  	=      ["ImageGPTImageProcessor"]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase__  	=      [
						    "IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST",
						    "ImageGPTForCausalImageModeling",
						    "ImageGPTForImageClassification",
						    "ImageGPTModel",
						    "ImageGPTPreTrainedModel",
						    "load_tf_weights_in_imagegpt",
						]


if TYPE_CHECKING:
						from .configuration_imagegpt import IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, ImageGPTConfig, ImageGPTOnnxConfig

						try:
												if not is_vision_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .feature_extraction_imagegpt import ImageGPTFeatureExtractor
												from .image_processing_imagegpt import ImageGPTImageProcessor

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_imagegpt import (
												    IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
												    ImageGPTForCausalImageModeling,
												    ImageGPTForImageClassification,
												    ImageGPTModel,
												    ImageGPTPreTrainedModel,
												    load_tf_weights_in_imagegpt,
												)

else:
						import sys

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





def 	__lowerCamelCase							(				__a    : float		)      ->       float:
	return -num if num < 0 else num

def 	__lowerCamelCase							(				__a    : list[int]		)      ->       int:
	if len(__a		) == 0:
		raise ValueError("abs_min() arg is an empty sequence"		)
	_lowercase   =x[0]
	for i in x:
		if abs_val(__a		) < abs_val(__a		):
			_lowercase   =i
	return j

def 	__lowerCamelCase							(				__a    : list[int]		)      ->       int:
	if len(__a		) == 0:
		raise ValueError("abs_max() arg is an empty sequence"		)
	_lowercase   =x[0]
	for i in x:
		if abs(__a		) > abs(__a		):
			_lowercase   =i
	return j

def 	__lowerCamelCase							(				__a    : list[int]		)      ->       int:
	if len(__a		) == 0:
		raise ValueError("abs_max_sort() arg is an empty sequence"		)
	return sorted(__a      ,							key=__a		)[-1]

def 	__lowerCamelCase							(				)      ->       Optional[Any]:
	assert abs_val(0		) == 0
	assert abs_val(34		) == 34
	assert abs_val(-100_000_000_000		) == 100_000_000_000

	_lowercase   =[-3, -1, 2, -11]
	assert abs_max(__a		) == -11
	assert abs_max_sort(__a		) == -11
	assert abs_min(__a		) == -1


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						test_abs_val()
						print(abs_val(-3_4))  # --> 34




