code: 
  
  
  
  import os
  import pathlib
  import tempfile
  import uuid
  
  import numpy as np
  
  from ..utils import is_soundfile_availble, is_torch_available, is_vision_available, logging
  
  
  lowerCAmelCase__	:  Optional[Any] 		=logging.get_logger(__name__)
  
  if is_vision_available():
  			import PIL.Image
  			from PIL import Image
  			from PIL.Image import Image as ImageType
  else:
  			lowerCAmelCase__	:  str 		=object
  
  if is_torch_available():
  			import torch
  
  if is_soundfile_availble():
  			import soundfile as sf
  
  class      UpperCAmelCase_						:
  
  						'''simple docstring'''
  
  
  
  
  						def __init__(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      value
  
  
  
  
  
  
  						def __str__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self.to_string()
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													logger.error(
  													    'This is a raw AgentType of unknown type. Display in notebooks and string conversion will be unreliable'	)
  													return self._value
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													logger.error(
  													    'This is a raw AgentType of unknown type. Display in notebooks and string conversion will be unreliable'	)
  													return str(self._value	)
  
  
  
  
  
  
  
  class      UpperCAmelCase_						(     UpperCamelCase_					,					UpperCamelCase_ ):
  
  						'''simple docstring'''
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._value
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._value
  
  
  
  
  
  
  
  class      UpperCAmelCase_						(     UpperCamelCase_					,					UpperCamelCase_ ):
  
  						'''simple docstring'''
  
  
  
  
  						def __init__(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													super().__init__(_A	)
  
  													if not is_vision_available():
  																				raise ImportError('PIL must be installed in order to handle images.'	)
  
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      None
  
  													if isinstance(_A   ,							_A	):
  																				__SCREAMING_SNAKE_CASE								=      value
  													elif isinstance(_A   ,							(str, pathlib.Path)	):
  																				__SCREAMING_SNAKE_CASE								=      value
  													elif isinstance(_A   ,							torch.Tensor	):
  																				__SCREAMING_SNAKE_CASE								=      value
  													else:
  																				raise ValueError(f"""Unsupported type for {self.__class__.__name__}: {type(_A	)}"""	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A=None   ,							_A=None	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													from IPython.display import Image, display
  
  													display(Image(self.to_string()	)	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if self._raw is not None:
  																				return self._raw
  
  													if self._path is not None:
  																				__SCREAMING_SNAKE_CASE								=      Image.open(self._path	)
  																				return self._raw
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if self._path is not None:
  																				return self._path
  
  													if self._raw is not None:
  																				__SCREAMING_SNAKE_CASE								=      tempfile.mkdtemp()
  																				__SCREAMING_SNAKE_CASE								=      os.path.join(_A   ,							str(uuid.uuida()	) + '.png'	)
  																				self._raw.save(self._path	)
  
  																				return self._path
  
  													if self._tensor is not None:
  																				__SCREAMING_SNAKE_CASE								=      self._tensor.cpu().detach().numpy()
  
  																				# There is likely simpler than load into image into save
  																				__SCREAMING_SNAKE_CASE								=      Image.fromarray((array * 255).astype(np.uinta	)	)
  
  																				__SCREAMING_SNAKE_CASE								=      tempfile.mkdtemp()
  																				__SCREAMING_SNAKE_CASE								=      os.path.join(_A   ,							str(uuid.uuida()	) + '.png'	)
  
  																				img.save(self._path	)
  
  																				return self._path
  
  
  
  
  
  
  
  class      UpperCAmelCase_						(     UpperCamelCase_ ):
  
  						'''simple docstring'''
  
  
  
  
  						def __init__(					self   ,							_A   ,							_A=16_000	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													super().__init__(_A	)
  
  													if not is_soundfile_availble():
  																				raise ImportError('soundfile must be installed in order to handle audio.'	)
  
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      None
  
  													__SCREAMING_SNAKE_CASE								=      samplerate
  
  													if isinstance(_A   ,							(str, pathlib.Path)	):
  																				__SCREAMING_SNAKE_CASE								=      value
  													elif isinstance(_A   ,							torch.Tensor	):
  																				__SCREAMING_SNAKE_CASE								=      value
  													else:
  																				raise ValueError(f"""Unsupported audio type: {type(_A	)}"""	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A=None   ,							_A=None	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													from IPython.display import Audio, display
  
  													display(Audio(self.to_string()   ,							rate=self.samplerate	)	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if self._tensor is not None:
  																				return self._tensor
  
  													if self._path is not None:
  																				__SCREAMING_SNAKE_CASE							, __SCREAMING_SNAKE_CASE								=      sf.read(self._path	)
  																				__SCREAMING_SNAKE_CASE								=      torch.tensor(_A	)
  																				return self._tensor
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if self._path is not None:
  																				return self._path
  
  													if self._tensor is not None:
  																				__SCREAMING_SNAKE_CASE								=      tempfile.mkdtemp()
  																				__SCREAMING_SNAKE_CASE								=      os.path.join(_A   ,							str(uuid.uuida()	) + '.wav'	)
  																				sf.write(self._path   ,							self._tensor   ,							samplerate=self.samplerate	)
  																				return self._path
  
  
  
  
  
  
  
  lowerCAmelCase__	:  List[Any] 		={'''text''': AgentText, '''image''': AgentImage, '''audio''': AgentAudio}
  lowerCAmelCase__	:  Dict 		={str: AgentText}
  
  if is_vision_available():
  			lowerCAmelCase__	:  int 		=AgentImage
  
  
  
  
  
  
  def 			__lowercase     (				*a__							,     **a__     )       ->				List[str]:
  							__SCREAMING_SNAKE_CASE								=      [(arg.to_raw() if isinstance(a__							,     a__     ) else arg) for arg in args]
  							__SCREAMING_SNAKE_CASE								=      {k: (v.to_raw() if isinstance(a__							,     a__     ) else v) for k, v in kwargs.items()}
  							return args, kwargs
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__=None     )       ->				List[Any]:
  							if isinstance(a__							,     a__     ):
  														__SCREAMING_SNAKE_CASE								=      {}
  														for i, (k, v) in enumerate(outputs.items()     ):
  																					if output_types is not None:
  																												# If the class has defined outputs, we can map directly according to the class definition
  																												if output_types[i] in AGENT_TYPE_MAPPING:
  																																			__SCREAMING_SNAKE_CASE								=      AGENT_TYPE_MAPPING[output_types[i]](a__     )
  																												else:
  																																			__SCREAMING_SNAKE_CASE								=      AgentType(a__     )
  
  																					else:
  																												# If the class does not have defined output, then we map according to the type
  																												for _k, _v in INSTANCE_TYPE_MAPPING.items():
  																																			if isinstance(a__							,     _k     ):
  																																										__SCREAMING_SNAKE_CASE								=      _v(a__     )
  																												if k not in decoded_outputs:
  																																			__SCREAMING_SNAKE_CASE								=      AgentType[v]
  
  							elif isinstance(a__							,     (list, tuple)     ):
  														__SCREAMING_SNAKE_CASE								=      type(a__     )()
  														for i, v in enumerate(a__     ):
  																					if output_types is not None:
  																												# If the class has defined outputs, we can map directly according to the class definition
  																												if output_types[i] in AGENT_TYPE_MAPPING:
  																																			decoded_outputs.append(AGENT_TYPE_MAPPING[output_types[i]](a__     )     )
  																												else:
  																																			decoded_outputs.append(AgentType(a__     )     )
  																					else:
  																												# If the class does not have defined output, then we map according to the type
  																												__SCREAMING_SNAKE_CASE								=      False
  																												for _k, _v in INSTANCE_TYPE_MAPPING.items():
  																																			if isinstance(a__							,     _k     ):
  																																										decoded_outputs.append(_v(a__     )     )
  																																										__SCREAMING_SNAKE_CASE								=      True
  
  																												if not found:
  																																			decoded_outputs.append(AgentType(a__     )     )
  
  							else:
  														if output_types[0] in AGENT_TYPE_MAPPING:
  																					# If the class has defined outputs, we can map directly according to the class definition
  																					__SCREAMING_SNAKE_CASE								=      AGENT_TYPE_MAPPING[output_types[0]](a__     )
  
  														else:
  																					# If the class does not have defined output, then we map according to the type
  																					for _k, _v in INSTANCE_TYPE_MAPPING.items():
  																												if isinstance(a__							,     _k     ):
  																																			return _v(a__     )
  																					return AgentType(a__     )
  
  							return decoded_outputs
  
  
  
  
  
  
  
style_context: 
  
  
  
  def 			__lowercase     (				a__							,     a__     )       ->				List[str]:
  							if n == 0:
  														return 1
  
  							elif n % 2 == 1:
  														return binary_exponentiation(a__							,     n - 1     ) * a
  
  							else:
  														__SCREAMING_SNAKE_CASE								=      binary_exponentiation(a__							,     n / 2     )
  														return b * b
  
  
  if __name__ == "__main__":
  			try:
  						lowerCAmelCase__	:  str 		=int(input('''Enter Base : ''').strip())
  						lowerCAmelCase__	:  Optional[int] 		=int(input('''Enter Power : ''').strip())
  			except ValueError:
  						print('''Invalid literal for integer''')
  
  			lowerCAmelCase__	:  Any 		=binary_exponentiation(BASE, POWER)
  			print(F'''{BASE}^({POWER}) : {RESULT}''')
  
  
  
  
  
  
  