



'''simple docstring'''





from typing import Dict, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image
from ...image_utils import (
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_pytesseract_available, is_vision_available, logging, requires_backends


if is_vision_available():
		import PIL

# soft dependency
if is_pytesseract_available():
		import pytesseract

lowercase_	 =						logging.get_logger(__name__)




def lowerCAmelCase						(__A						,			__A						,			__A):



					"""simple docstring"""



					return [
					    int(1_000 * (box[0] / width)),
					    int(1_000 * (box[1] / height)),
					    int(1_000 * (box[2] / width)),
					    int(1_000 * (box[3] / height)),
					]




def lowerCAmelCase						(__A						,			__A						,			__A = None):



					"""simple docstring"""



					_a											=						tesseract_config if tesseract_config is not None else ''''''

					# apply OCR
					_a											=						to_pil_image(__A)
					_a											=						pil_image.size
					_a											=						pytesseract.image_to_data(__A						,			lang=__A						,			output_type='''dict'''						,			config=__A)
					_a											=						data['''text'''], data['''left'''], data['''top'''], data['''width'''], data['''height''']

					# filter empty words and corresponding coordinates
					_a											=						[idx for idx, word in enumerate(__A) if not word.strip()]
					_a											=						[word for idx, word in enumerate(__A) if idx not in irrelevant_indices]
					_a											=						[coord for idx, coord in enumerate(__A) if idx not in irrelevant_indices]
					_a											=						[coord for idx, coord in enumerate(__A) if idx not in irrelevant_indices]
					_a											=						[coord for idx, coord in enumerate(__A) if idx not in irrelevant_indices]
					_a											=						[coord for idx, coord in enumerate(__A) if idx not in irrelevant_indices]

					# turn coordinates into (left, top, left+width, top+height) format
					_a											=						[]
					for x, y, w, h in zip(__A						,			__A						,			__A						,			__A):
										_a											=						[x, y, x + w, y + h]
										actual_boxes.append(__A)

					# finally, normalize the bounding boxes
					_a											=						[]
					for box in actual_boxes:
										normalized_boxes.append(normalize_box(__A						,			__A						,			__A))

					assert len(__A) == len(__A), "Not as many words as there are bounding boxes"

					return words, normalized_boxes






class __A    (						A		):



	'''simple docstring'''







	__lowerCamelCase					: int    = ['pixel_values']



	def __init__(self				,     A = True				,     A = None				,     A = PILImageResampling.BILINEAR				,     A = True				,     A = None				,     A = ""				,     **A				,     )					->  Dict:


						"""simple docstring"""



						super().__init__(**UpperCAmelCase__ )
						_a											=						size if size is not None else {'''height''': 224, '''width''': 224}
						_a											=						get_size_dict(UpperCAmelCase__ )

						_a											=						do_resize
						_a											=						size
						_a											=						resample
						_a											=						apply_ocr
						_a											=						ocr_lang
						_a											=						tesseract_config



	def       a__						(self				,     A				,     A				,     A = PILImageResampling.BILINEAR				,     A = None				,     **A				,     )					->  Optional[Any]:


						"""simple docstring"""



						_a											=						get_size_dict(UpperCAmelCase__ )
						if "height" not in size or "width" not in size:
											raise ValueError(f'''The size dictionary must contain the keys \'height\' and \'width\'. Got {size.keys()}''' )
						_a											=						(size['''height'''], size['''width'''])
						return resize(UpperCAmelCase__				,     size=UpperCAmelCase__				,     resample=UpperCAmelCase__				,     data_format=UpperCAmelCase__				,     **UpperCAmelCase__ )



	def       a__						(self				,     A				,     A = None				,     A = None				,     A = None				,     A = None				,     A = None				,     A = None				,     A = None				,     A = ChannelDimension.FIRST				,     **A				,     )					->  str:


						"""simple docstring"""



						_a											=						do_resize if do_resize is not None else self.do_resize
						_a											=						size if size is not None else self.size
						_a											=						get_size_dict(UpperCAmelCase__ )
						_a											=						resample if resample is not None else self.resample
						_a											=						apply_ocr if apply_ocr is not None else self.apply_ocr
						_a											=						ocr_lang if ocr_lang is not None else self.ocr_lang
						_a											=						tesseract_config if tesseract_config is not None else self.tesseract_config

						_a											=						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_resize and size is None:
											raise ValueError('''Size must be specified if do_resize is True.''' )

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

						if apply_ocr:
											requires_backends(self				,     '''pytesseract''' )
											_a											=						[]
											_a											=						[]
											for image in images:
																_a											=						apply_tesseract(UpperCAmelCase__				,     UpperCAmelCase__				,     UpperCAmelCase__ )
																words_batch.append(UpperCAmelCase__ )
																boxes_batch.append(UpperCAmelCase__ )

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

						# flip color channels from RGB to BGR (as Detectron2 requires this)
						_a											=						[flip_channel_order(UpperCAmelCase__ ) for image in images]
						_a											=						[to_channel_dimension_format(UpperCAmelCase__				,     UpperCAmelCase__ ) for image in images]

						_a											=						BatchFeature(data={'''pixel_values''': images}				,     tensor_type=UpperCAmelCase__ )

						if apply_ocr:
											_a											=						words_batch
											_a											=						boxes_batch
						return data








'''simple docstring'''





def lowerCAmelCase						(__A = 1_000):



     """simple docstring"""



     _a											=						2**power
     _a											=						str(__A)
     _a											=						list(__A)
     _a											=						0

     for i in list_num:
          sum_of_num += int(__A)

     return sum_of_num


if __name__ == "__main__":
  lowercase_	 =						int(input("Enter the power of 2: ").strip())
  print("2 ^ ", power, " = ", 2**power)
  lowercase_	 =						solution(power)
  print("Sum of the digits is: ", result)



