






"""simple docstring"""



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


_UpperCamelCase						=		logging.get_logger(__name__)

if is_vision_available():
    import PIL.Image
    from PIL import Image
    from PIL.Image import Image as ImageType
else:
    _UpperCamelCase						=		object

if is_torch_available():
    import torch

if is_soundfile_availble():
    import soundfile as sf

class 	a					:







    def __init__(      self							,		_lowerCamelCase	):
      lowercase							   =	value







    def __str__(      self	):
      return self.to_string()







    def       UpperCamelCase_				(      self	):
      logger.error(
          'This is a raw AgentType of unknown type. Display in notebooks and string conversion will be unreliable'	)
      return self._value







    def       UpperCamelCase_				(      self	):
      logger.error(
          'This is a raw AgentType of unknown type. Display in notebooks and string conversion will be unreliable'	)
      return str(self._value	)


class 	a					(       _lowerCAmelCase,    _lowerCAmelCase     ):







    def       UpperCamelCase_				(      self	):
      return self._value







    def       UpperCamelCase_				(      self	):
      return self._value


class 	a					(       _lowerCAmelCase,    _lowerCAmelCase     ):







    def __init__(      self							,		_lowerCamelCase	):
      super().__init__(_lowerCamelCase	)

      if not is_vision_available():
        raise ImportError('PIL must be installed in order to handle images.'	)

      lowercase							   =	None
      lowercase							   =	None
      lowercase							   =	None

      if isinstance(_lowerCamelCase							,		_lowerCamelCase	):
        lowercase							   =	value
      elif isinstance(_lowerCamelCase							,		(str, pathlib.Path)	):
        lowercase							   =	value
      elif isinstance(_lowerCamelCase							,		torch.Tensor	):
        lowercase							   =	value
      else:
        raise ValueError(F'Unsupported type for {self.__class__.__name__}: {type(_lowerCamelCase	)}'	)







    def       UpperCamelCase_				(      self							,		_lowerCamelCase=None							,		_lowerCamelCase=None	):
      from IPython.display import Image, display

      display(Image(self.to_string()	)	)







    def       UpperCamelCase_				(      self	):
      if self._raw is not None:
        return self._raw

      if self._path is not None:
        lowercase							   =	Image.open(self._path	)
        return self._raw







    def       UpperCamelCase_				(      self	):
      if self._path is not None:
        return self._path

      if self._raw is not None:
        lowercase							   =	tempfile.mkdtemp()
        lowercase							   =	os.path.join(_lowerCamelCase							,		str(uuid.uuida()	) + '.png'	)
        self._raw.save(self._path	)

        return self._path

      if self._tensor is not None:
        lowercase							   =	self._tensor.cpu().detach().numpy()

        # There is likely simpler than load into image into save
        lowercase							   =	Image.fromarray((array * 2_5_5).astype(np.uinta	)	)

        lowercase							   =	tempfile.mkdtemp()
        lowercase							   =	os.path.join(_lowerCamelCase							,		str(uuid.uuida()	) + '.png'	)

        img.save(self._path	)

        return self._path


class 	a					(       _lowerCAmelCase     ):







    def __init__(      self							,		_lowerCamelCase							,		_lowerCamelCase=1_6_0_0_0	):
      super().__init__(_lowerCamelCase	)

      if not is_soundfile_availble():
        raise ImportError('soundfile must be installed in order to handle audio.'	)

      lowercase							   =	None
      lowercase							   =	None

      lowercase							   =	samplerate

      if isinstance(_lowerCamelCase							,		(str, pathlib.Path)	):
        lowercase							   =	value
      elif isinstance(_lowerCamelCase							,		torch.Tensor	):
        lowercase							   =	value
      else:
        raise ValueError(F'Unsupported audio type: {type(_lowerCamelCase	)}'	)







    def       UpperCamelCase_				(      self							,		_lowerCamelCase=None							,		_lowerCamelCase=None	):
      from IPython.display import Audio, display

      display(Audio(self.to_string()							,		rate=self.samplerate	)	)







    def       UpperCamelCase_				(      self	):
      if self._tensor is not None:
        return self._tensor

      if self._path is not None:
        lowercase   ,					lowercase							   =	sf.read(self._path	)
        lowercase							   =	torch.tensor(_lowerCamelCase	)
        return self._tensor







    def       UpperCamelCase_				(      self	):
      if self._path is not None:
        return self._path

      if self._tensor is not None:
        lowercase							   =	tempfile.mkdtemp()
        lowercase							   =	os.path.join(_lowerCamelCase							,		str(uuid.uuida()	) + '.wav'	)
        sf.write(self._path							,		self._tensor							,		samplerate=self.samplerate	)
        return self._path


_UpperCamelCase						=		{'text': AgentText, 'image': AgentImage, 'audio': AgentAudio}
_UpperCamelCase						=		{str: AgentText}

if is_vision_available():
    _UpperCamelCase						=		AgentImage
def 						_SCREAMING_SNAKE_CASE			(   *__snake_case      :  Optional[Any]		, **__snake_case      :  Optional[Any]   ):





  '''simple docstring'''





  lowercase							   =	[(arg.to_raw() if isinstance(__UpperCamelCase		, __UpperCamelCase   ) else arg) for arg in args]
  lowercase							   =	{k: (v.to_raw() if isinstance(__UpperCamelCase		, __UpperCamelCase   ) else v) for k, v in kwargs.items()}
  return args, kwargs



def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  str		, __snake_case      :  Union[str, Any]=None   ):





  '''simple docstring'''





  if isinstance(__UpperCamelCase		, __UpperCamelCase   ):
    lowercase							   =	{}
    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:
          lowercase							   =	AGENT_TYPE_MAPPING[output_types[i]](__UpperCamelCase   )
        else:
          lowercase							   =	AgentType(__UpperCamelCase   )

      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(__UpperCamelCase		, _k   ):
            lowercase							   =	_v(__UpperCamelCase   )
        if k not in decoded_outputs:
          lowercase							   =	AgentType[v]

  elif isinstance(__UpperCamelCase		, (list, tuple)   ):
    lowercase							   =	type(__UpperCamelCase   )()
    for i, v in enumerate(__UpperCamelCase   ):
      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]](__UpperCamelCase   )   )
        else:
          decoded_outputs.append(AgentType(__UpperCamelCase   )   )
      else:
        # If the class does not have defined output, then we map according to the type
        lowercase							   =	False
        for _k, _v in INSTANCE_TYPE_MAPPING.items():
          if isinstance(__UpperCamelCase		, _k   ):
            decoded_outputs.append(_v(__UpperCamelCase   )   )
            lowercase							   =	True

        if not found:
          decoded_outputs.append(AgentType(__UpperCamelCase   )   )

  else:
    if output_types[0] in AGENT_TYPE_MAPPING:
      # If the class has defined outputs, we can map directly according to the class definition
      lowercase							   =	AGENT_TYPE_MAPPING[output_types[0]](__UpperCamelCase   )

    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(__UpperCamelCase		, _k   ):
          return _v(__UpperCamelCase   )
      return AgentType(__UpperCamelCase   )

  return decoded_outputs










"""simple docstring"""



_UpperCamelCase		:  str						=		1_0**8
def 						_SCREAMING_SNAKE_CASE			(   __snake_case      :  int   ):





  '''simple docstring'''





  if n % 10 == 0:
    return False
  lowercase							   =	str(__snake_case   )
  return s == s[::-1]
def 						_SCREAMING_SNAKE_CASE			(   ):





  '''simple docstring'''





  lowercase							   =	set()
  lowercase							   =	1
  lowercase							   =	5
  while sum_squares < LIMIT:
    lowercase							   =	first_square + 1
    while sum_squares < LIMIT:
      if is_palindrome(__snake_case   ):
        answer.add(__snake_case   )
      last_square += 1
      sum_squares += last_square**2
    first_square += 1
    lowercase							   =	first_square**2 + (first_square + 1) ** 2

  return sum(__snake_case   )


if __name__ == "__main__":
    print(solution())


