

import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
       import torch

if is_vision_available():
       from PIL import Image

       from transformers import GLPNImageProcessor






class  UpperCAmelCase__	( unittest.TestCase ):






  """simple docstring"""


  def __init__(							self		:	Union[str, Any]			,     __lowerCamelCase		:	Union[str, Any]			,     __lowerCamelCase		:	int=7			,     __lowerCamelCase		:	List[str]=3			,     __lowerCamelCase		:	Any=18			,     __lowerCamelCase		:	Dict=30			,     __lowerCamelCase		:	Optional[int]=400			,     __lowerCamelCase		:	Tuple=True			,     __lowerCamelCase		:	Union[str, Any]=32			,     __lowerCamelCase		:	Optional[int]=True			,     )	->							Optional[int]:
       SCREAMING_SNAKE_CASE__					=					parent
       SCREAMING_SNAKE_CASE__					=					batch_size
       SCREAMING_SNAKE_CASE__					=					num_channels
       SCREAMING_SNAKE_CASE__					=					image_size
       SCREAMING_SNAKE_CASE__					=					min_resolution
       SCREAMING_SNAKE_CASE__					=					max_resolution
       SCREAMING_SNAKE_CASE__					=					do_resize
       SCREAMING_SNAKE_CASE__					=					size_divisor
       SCREAMING_SNAKE_CASE__					=					do_rescale







  def    lowercase_	(							self		:	Optional[int]      )	->							Optional[Any]:
       return {
           "do_resize": self.do_resize,
           "size_divisor": self.size_divisor,
           "do_rescale": self.do_rescale,
       }






@require_torch
@require_vision
class  UpperCAmelCase__	( A__		,  unittest.TestCase ):






  """simple docstring"""


  a     =      GLPNImageProcessor if is_vision_available() else None






  def    lowercase_	(							self		:	List[Any]      )	->							Optional[int]:
       SCREAMING_SNAKE_CASE__					=					GLPNImageProcessingTester(self      )






  @property
  def    lowercase_	(							self		:	Optional[int]      )	->							Any:
       return self.image_processor_tester.prepare_image_processor_dict()






  def    lowercase_	(							self		:	Any      )	->							Tuple:
       SCREAMING_SNAKE_CASE__					=					self.image_processing_class(**self.image_processor_dict      )
       self.assertTrue(hasattr(__lowerCamelCase			,     '''do_resize'''      )      )
       self.assertTrue(hasattr(__lowerCamelCase			,     '''size_divisor'''      )      )
       self.assertTrue(hasattr(__lowerCamelCase			,     '''resample'''      )      )
       self.assertTrue(hasattr(__lowerCamelCase			,     '''do_rescale'''      )      )






  def    lowercase_	(							self		:	Union[str, Any]      )	->							Any:
       pass






  def    lowercase_	(							self		:	Any      )	->							Optional[Any]:
       # Initialize image_processing
       SCREAMING_SNAKE_CASE__					=					self.image_processing_class(**self.image_processor_dict      )
       # create random PIL images
       SCREAMING_SNAKE_CASE__					=					prepare_image_inputs(self.image_processor_tester			,     equal_resolution=__lowerCamelCase      )
       for image in image_inputs:
            self.assertIsInstance(__lowerCamelCase			,     Image.Image      )

       # Test not batched input (GLPNImageProcessor doesn't support batching)
       SCREAMING_SNAKE_CASE__					=					image_processing(image_inputs[0]			,     return_tensors='''pt'''      ).pixel_values
       self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0      )
       self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0      )






  def    lowercase_	(							self		:	int      )	->							Any:
       # Initialize image_processing
       SCREAMING_SNAKE_CASE__					=					self.image_processing_class(**self.image_processor_dict      )
       # create random numpy tensors
       SCREAMING_SNAKE_CASE__					=					prepare_image_inputs(self.image_processor_tester			,     equal_resolution=__lowerCamelCase			,     numpify=__lowerCamelCase      )
       for image in image_inputs:
            self.assertIsInstance(__lowerCamelCase			,     np.ndarray      )

       # Test not batched input (GLPNImageProcessor doesn't support batching)
       SCREAMING_SNAKE_CASE__					=					image_processing(image_inputs[0]			,     return_tensors='''pt'''      ).pixel_values
       self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0      )
       self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0      )







  def    lowercase_	(							self		:	Optional[int]      )	->							Dict:
       # Initialize image_processing
       SCREAMING_SNAKE_CASE__					=					self.image_processing_class(**self.image_processor_dict      )
       # create random PyTorch tensors
       SCREAMING_SNAKE_CASE__					=					prepare_image_inputs(self.image_processor_tester			,     equal_resolution=__lowerCamelCase			,     torchify=__lowerCamelCase      )
       for image in image_inputs:
            self.assertIsInstance(__lowerCamelCase			,     torch.Tensor      )

       # Test not batched input (GLPNImageProcessor doesn't support batching)
       SCREAMING_SNAKE_CASE__					=					image_processing(image_inputs[0]			,     return_tensors='''pt'''      ).pixel_values
       self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0      )
       self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0      )





from typing import List

import datasets
from datasets.tasks import AudioClassification

from ..folder_based_builder import folder_based_builder


_SCREAMING_SNAKE_CASE  :						Optional[Any]         =    datasets.utils.logging.get_logger(__name__)






class  UpperCAmelCase__	( folder_based_builder.FolderBasedBuilderConfig ):






  """simple docstring"""


  a     =      None
  a     =      None






class  UpperCAmelCase__	( folder_based_builder.FolderBasedBuilder ):






  """simple docstring"""


  a     =      datasets.Audio()
  a     =      "audio"
  a     =      AudioFolderConfig
  a     =      42  # definition at the bottom of the script
  a     =      AudioClassification(audio_column="audio"		,  label_column="label" )



_SCREAMING_SNAKE_CASE  :						str         =    [
    '''.aiff''',
    '''.au''',
    '''.avr''',
    '''.caf''',
    '''.flac''',
    '''.htk''',
    '''.svx''',
    '''.mat4''',
    '''.mat5''',
    '''.mpc2k''',
    '''.ogg''',
    '''.paf''',
    '''.pvf''',
    '''.raw''',
    '''.rf64''',
    '''.sd2''',
    '''.sds''',
    '''.ircam''',
    '''.voc''',
    '''.w64''',
    '''.wav''',
    '''.nist''',
    '''.wavex''',
    '''.wve''',
    '''.xi''',
    '''.mp3''',
    '''.opus''',
]
_SCREAMING_SNAKE_CASE  :						List[Any]         =    AUDIO_EXTENSIONS


