

'''simple docstring'''

from ..utils import DummyObject, requires_backends





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     List[Any]       =					['''flax''']
   def __init__( self			:      List[Any]     ,*SCREAMING_SNAKE_CASE__			:      List[str]     ,**SCREAMING_SNAKE_CASE__			:      int							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[int]     ,*SCREAMING_SNAKE_CASE__			:      List[str]     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      List[str]     ,*SCREAMING_SNAKE_CASE__			:      Optional[Any]     ,**SCREAMING_SNAKE_CASE__			:      str							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     int       =					['''flax''']
   def __init__( self			:      Union[str, Any]     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      Optional[int]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      str     ,*SCREAMING_SNAKE_CASE__			:      Any     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      List[Any]     ,*SCREAMING_SNAKE_CASE__			:      int     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Optional[Any]       =					['''flax''']
   def __init__( self			:      Tuple     ,*SCREAMING_SNAKE_CASE__			:      List[Any]     ,**SCREAMING_SNAKE_CASE__			:      List[str]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[int]     ,*SCREAMING_SNAKE_CASE__			:      Optional[Any]     ,**SCREAMING_SNAKE_CASE__			:      Optional[int]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      str     ,*SCREAMING_SNAKE_CASE__			:      List[str]     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Tuple       =					['''flax''']
   def __init__( self			:      str     ,*SCREAMING_SNAKE_CASE__			:      Tuple     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      List[str]     ,*SCREAMING_SNAKE_CASE__			:      Any     ,**SCREAMING_SNAKE_CASE__			:      Optional[Any]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      Tuple     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Union[str, Any]       =					['''flax''']
   def __init__( self			:      str     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[int]     ,*SCREAMING_SNAKE_CASE__			:      Optional[Any]     ,**SCREAMING_SNAKE_CASE__			:      int							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      List[Any]     ,*SCREAMING_SNAKE_CASE__			:      int     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     int       =					['''flax''']
   def __init__( self			:      int     ,*SCREAMING_SNAKE_CASE__			:      Tuple     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Tuple     ,*SCREAMING_SNAKE_CASE__			:      str     ,**SCREAMING_SNAKE_CASE__			:      int							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      List[str]     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Optional[int]       =					['''flax''']
   def __init__( self			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      Union[str, Any]     ,**SCREAMING_SNAKE_CASE__			:      Dict							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Tuple     ,*SCREAMING_SNAKE_CASE__			:      str     ,**SCREAMING_SNAKE_CASE__			:      Any							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[int]     ,*SCREAMING_SNAKE_CASE__			:      List[str]     ,**SCREAMING_SNAKE_CASE__			:      str							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Dict       =					['''flax''']
   def __init__( self			:      Any     ,*SCREAMING_SNAKE_CASE__			:      Any     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      List[Any]     ,*SCREAMING_SNAKE_CASE__			:      Union[str, Any]     ,**SCREAMING_SNAKE_CASE__			:      Dict							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Any     ,*SCREAMING_SNAKE_CASE__			:      Any     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Dict       =					['''flax''']
   def __init__( self			:      Dict     ,*SCREAMING_SNAKE_CASE__			:      Tuple     ,**SCREAMING_SNAKE_CASE__			:      List[str]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Any     ,*SCREAMING_SNAKE_CASE__			:      List[str]     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Union[str, Any]     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      str							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Optional[Any]       =					['''flax''']
   def __init__( self			:      Optional[int]     ,*SCREAMING_SNAKE_CASE__			:      str     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      Tuple     ,**SCREAMING_SNAKE_CASE__			:      str							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      int     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     List[str]       =					['''flax''']
   def __init__( self			:      int     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      List[str]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      List[Any]     ,**SCREAMING_SNAKE_CASE__			:      List[Any]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Any     ,*SCREAMING_SNAKE_CASE__			:      Tuple     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     Tuple       =					['''flax''']
   def __init__( self			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      int     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Tuple     ,*SCREAMING_SNAKE_CASE__			:      List[Any]     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Optional[Any]     ,*SCREAMING_SNAKE_CASE__			:      List[str]     ,**SCREAMING_SNAKE_CASE__			:      Optional[int]							):
     requires_backends(cls     ,["flax"]							)





class 							_snake_case (       metaclass=__lowercase						):
   _A       :     str       =					['''flax''']
   def __init__( self			:      Dict     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      Dict							):
     requires_backends(self     ,["flax"]							)
   @classmethod
   def     __UpperCamelCase						( cls			:      Union[str, Any]     ,*SCREAMING_SNAKE_CASE__			:      List[Any]     ,**SCREAMING_SNAKE_CASE__			:      Union[str, Any]							):
     requires_backends(cls     ,["flax"]							)







   @classmethod
   def     __UpperCamelCase						( cls			:      Any     ,*SCREAMING_SNAKE_CASE__			:      Optional[int]     ,**SCREAMING_SNAKE_CASE__			:      Tuple							):
     requires_backends(cls     ,["flax"]							)





'''simple docstring'''

import PIL.Image
import PIL.ImageOps
from packaging import version
from PIL import Image


if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"):
    A_       						=							{
        "linear": PIL.Image.Resampling.BILINEAR,
        "bilinear": PIL.Image.Resampling.BILINEAR,
        "bicubic": PIL.Image.Resampling.BICUBIC,
        "lanczos": PIL.Image.Resampling.LANCZOS,
        "nearest": PIL.Image.Resampling.NEAREST,
    }
else:
    A_       						=							{
        "linear": PIL.Image.LINEAR,
        "bilinear": PIL.Image.BILINEAR,
        "bicubic": PIL.Image.BICUBIC,
        "lanczos": PIL.Image.LANCZOS,
        "nearest": PIL.Image.NEAREST,
    }





def    A_  ( snake_case ):
  SCREAMING_SNAKE_CASE:Any						      =					(images / 2 + 0.5).clamp(0      ,       1 )
  SCREAMING_SNAKE_CASE:Optional[Any]						      =					images.cpu().permute(0      ,       2      ,       3      ,       1 ).float().numpy()
  SCREAMING_SNAKE_CASE:str						      =					numpy_to_pil(snake_case )
  return images





def    A_  ( snake_case ):
  if images.ndim == 3:
    SCREAMING_SNAKE_CASE:List[str]						      =					images[None, ...]
  SCREAMING_SNAKE_CASE:List[Any]						      =					(images * 255).round().astype("uint8" )
  if images.shape[-1] == 1:
    # special case for grayscale (single channel) images
    SCREAMING_SNAKE_CASE:Any						      =					[Image.fromarray(image.squeeze()      ,       mode="L" ) for image in images]
  else:
    SCREAMING_SNAKE_CASE:int						      =					[Image.fromarray(snake_case ) for image in images]

  return pil_images






