


import inspect
from typing import Callable, List, Optional, Union

import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import DiffusionPipeline
from diffusers.models import AutoencoderKL, UNetaDConditionModel
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.schedulers import DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
from diffusers.utils import logging


a_ :Tuple  							=			logging.get_logger(__name__)  # pylint: disable=invalid-name

class 							lowercase  (						_UpperCAmelCase			):







     def __init__(						self :						Dict   ,   _lowercase :						AutoencoderKL   ,   _lowercase :						CLIPTextModel   ,   _lowercase :						CLIPTokenizer   ,   _lowercase :						UNetaDConditionModel   ,   _lowercase :						Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]   ,   _lowercase :						StableDiffusionSafetyChecker   ,   _lowercase :						CLIPImageProcessor   ,   ):
           super().__init__()
           self.register_modules(
               vae=_lowercase   ,   text_encoder=_lowercase   ,   tokenizer=_lowercase   ,   unet=_lowercase   ,   scheduler=_lowercase   ,   safety_checker=_lowercase   ,   feature_extractor=_lowercase   ,   )







     def 							lowercase__       (						self :						Tuple   ,   _lowercase :						Optional[Union[str, int]] = "auto"      ):
           if slice_size == "auto":
                 # half the attention head size is usually a good trade-off between
                 # speed and memory
                 SCREAMING_SNAKE_CASE__       :  Tuple						     =		self.unet.config.attention_head_dim // 2
           self.unet.set_attention_slice(_lowercase      )







     def 							lowercase__       (						self :						List[Any]      ):
           self.enable_attention_slicing(_lowercase      )







     @torch.no_grad()
     def __call__(						self :						Any   ,   _lowercase :						Union[str, List[str]]   ,   _lowercase :						int = 5_12   ,   _lowercase :						int = 5_12   ,   _lowercase :						int = 50   ,   _lowercase :						float = 7.5   ,   _lowercase :						Optional[Union[str, List[str]]] = None   ,   _lowercase :						Optional[int] = 1   ,   _lowercase :						float = 0.0   ,   _lowercase :						Optional[torch.Generator] = None   ,   _lowercase :						Optional[torch.FloatTensor] = None   ,   _lowercase :						Optional[str] = "pil"   ,   _lowercase :						bool = True   ,   _lowercase :						Optional[Callable[[int, int, torch.FloatTensor], None]] = None   ,   _lowercase :						int = 1   ,   _lowercase :						Optional[torch.FloatTensor] = None   ,   **_lowercase :						Dict   ,   ):

           if isinstance(_lowercase   ,   _lowercase      ):
                 SCREAMING_SNAKE_CASE__       :  str						     =		1
           elif isinstance(_lowercase   ,   _lowercase      ):
                 SCREAMING_SNAKE_CASE__       :  Any						     =		len(_lowercase      )
           else:
                 raise ValueError(f"""`prompt` has to be of type `str` or `list` but is {type(_lowercase      )}"""      )

           if height % 8 != 0 or width % 8 != 0:
                 raise ValueError(f"""`height` and `width` have to be divisible by 8 but are {height} and {width}."""      )

           if (callback_steps is None) or (
               callback_steps is not None and (not isinstance(_lowercase   ,   _lowercase      ) or callback_steps <= 0)
           ):
                 raise ValueError(
                     f"""`callback_steps` has to be a positive integer but is {callback_steps} of type"""
                     f""" {type(_lowercase      )}."""      )

           # get prompt text embeddings
           SCREAMING_SNAKE_CASE__       :  Any						     =		self.tokenizer(
               _lowercase   ,   padding='''max_length'''   ,   max_length=self.tokenizer.model_max_length   ,   return_tensors='''pt'''   ,   )
           SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		text_inputs.input_ids

           if text_input_ids.shape[-1] > self.tokenizer.model_max_length:
                 SCREAMING_SNAKE_CASE__       :  Tuple						     =		self.tokenizer.batch_decode(text_input_ids[:, self.tokenizer.model_max_length :]      )
                 logger.warning(
                     '''The following part of your input was truncated because CLIP can only handle sequences up to'''
                     f""" {self.tokenizer.model_max_length} tokens: {removed_text}"""      )
                 SCREAMING_SNAKE_CASE__       :  int						     =		text_input_ids[:, : self.tokenizer.model_max_length]

           if text_embeddings is None:
                 SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		self.text_encoder(text_input_ids.to(self.device      )      )[0]

           # duplicate text embeddings for each generation per prompt, using mps friendly method
           SCREAMING_SNAKE_CASE__     ,       SCREAMING_SNAKE_CASE__     ,       SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		text_embeddings.shape
           SCREAMING_SNAKE_CASE__       :  Any						     =		text_embeddings.repeat(1   ,   _lowercase   ,   1      )
           SCREAMING_SNAKE_CASE__       :  Tuple						     =		text_embeddings.view(bs_embed * num_images_per_prompt   ,   _lowercase   ,   -1      )

           # here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
           # of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
           # corresponds to doing no classifier free guidance.
           SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		guidance_scale > 1.0
           # get unconditional embeddings for classifier free guidance
           if do_classifier_free_guidance:
                 SCREAMING_SNAKE_CASE__       :  List[str]
                 if negative_prompt is None:
                       SCREAMING_SNAKE_CASE__       :  Any						     =		['''''']
                 elif type(_lowercase      ) is not type(_lowercase      ):
                       raise TypeError(
                           f"""`negative_prompt` should be the same type to `prompt`, but got {type(_lowercase      )} !="""
                           f""" {type(_lowercase      )}."""      )
                 elif isinstance(_lowercase   ,   _lowercase      ):
                       SCREAMING_SNAKE_CASE__       :  List[str]						     =		[negative_prompt]
                 elif batch_size != len(_lowercase      ):
                       raise ValueError(
                           f"""`negative_prompt`: {negative_prompt} has batch size {len(_lowercase      )}, but `prompt`:"""
                           f""" {prompt} has batch size {batch_size}. Please make sure that passed `negative_prompt` matches"""
                           ''' the batch size of `prompt`.'''      )
                 else:
                       SCREAMING_SNAKE_CASE__       :  Any						     =		negative_prompt

                 SCREAMING_SNAKE_CASE__       :  Tuple						     =		text_input_ids.shape[-1]
                 SCREAMING_SNAKE_CASE__       :  List[Any]						     =		self.tokenizer(
                     _lowercase   ,   padding='''max_length'''   ,   max_length=_lowercase   ,   truncation=_lowercase   ,   return_tensors='''pt'''   ,   )
                 SCREAMING_SNAKE_CASE__       :  List[str]						     =		self.text_encoder(uncond_input.input_ids.to(self.device      )      )[0]

                 # duplicate unconditional embeddings for each generation per prompt, using mps friendly method
                 SCREAMING_SNAKE_CASE__       :  int						     =		uncond_embeddings.shape[1]
                 SCREAMING_SNAKE_CASE__       :  List[Any]						     =		uncond_embeddings.repeat(_lowercase   ,   _lowercase   ,   1      )
                 SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		uncond_embeddings.view(batch_size * num_images_per_prompt   ,   _lowercase   ,   -1      )

                 # For classifier free guidance, we need to do two forward passes.
                 # Here we concatenate the unconditional and text embeddings into a single batch
                 # to avoid doing two forward passes
                 SCREAMING_SNAKE_CASE__       :  List[str]						     =		torch.cat([uncond_embeddings, text_embeddings]      )

           # get the initial random noise unless the user supplied it

           # Unlike in other pipelines, latents need to be generated in the target device
           # for 1-to-1 results reproducibility with the CompVis implementation.
           # However this currently doesn't work in `mps`.
           SCREAMING_SNAKE_CASE__       :  Union[str, Any]						     =		(batch_size * num_images_per_prompt, self.unet.config.in_channels, height // 8, width // 8)
           SCREAMING_SNAKE_CASE__       :  str						     =		(batch_size * num_images_per_prompt, self.unet.config.in_channels, 64, 64)
           SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		text_embeddings.dtype
           if latents is None:
                 if self.device.type == "mps":
                       # randn does not exist on mps
                       SCREAMING_SNAKE_CASE__       :  str						     =		torch.randn(
                           _lowercase   ,   generator=_lowercase   ,   device='''cpu'''   ,   dtype=_lowercase      ).to(self.device      )
                       SCREAMING_SNAKE_CASE__       :  List[str]						     =		torch.randn(_lowercase   ,   generator=_lowercase   ,   device='''cpu'''   ,   dtype=_lowercase      ).to(
                           self.device      )
                 else:
                       SCREAMING_SNAKE_CASE__       :  str						     =		torch.randn(
                           _lowercase   ,   generator=_lowercase   ,   device=self.device   ,   dtype=_lowercase      )
                       SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		torch.randn(_lowercase   ,   generator=_lowercase   ,   device=self.device   ,   dtype=_lowercase      )
           else:
                 if latents_reference.shape != latents_shape:
                       raise ValueError(f"""Unexpected latents shape, got {latents.shape}, expected {latents_shape}"""      )
                 SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		latents_reference.to(self.device      )
                 SCREAMING_SNAKE_CASE__       :  List[str]						     =		latents.to(self.device      )

           # This is the key part of the pipeline where we
           # try to ensure that the generated images w/ the same seed
           # but different sizes actually result in similar images
           SCREAMING_SNAKE_CASE__       :  List[Any]						     =		(latents_shape[3] - latents_shape_reference[3]) // 2
           SCREAMING_SNAKE_CASE__       :  Union[str, Any]						     =		(latents_shape[2] - latents_shape_reference[2]) // 2
           SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		latents_shape_reference[3] if dx >= 0 else latents_shape_reference[3] + 2 * dx
           SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		latents_shape_reference[2] if dy >= 0 else latents_shape_reference[2] + 2 * dy
           SCREAMING_SNAKE_CASE__       :  str						     =		0 if dx < 0 else dx
           SCREAMING_SNAKE_CASE__       :  int						     =		0 if dy < 0 else dy
           SCREAMING_SNAKE_CASE__       :  Any						     =		max(-dx   ,   0      )
           SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		max(-dy   ,   0      )
           # import pdb
           # pdb.set_trace()
           SCREAMING_SNAKE_CASE__       :  List[Any]						     =		latents_reference[:, :, dy : dy + h, dx : dx + w]

           # set timesteps
           self.scheduler.set_timesteps(_lowercase      )

           # Some schedulers like PNDM have timesteps as arrays
           # It's more optimized to move all timesteps to correct device beforehand
           SCREAMING_SNAKE_CASE__       :  Union[str, Any]						     =		self.scheduler.timesteps.to(self.device      )

           # scale the initial noise by the standard deviation required by the scheduler
           SCREAMING_SNAKE_CASE__       :  Any						     =		latents * self.scheduler.init_noise_sigma

           # prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
           # eta (η) is only used with the DDIMScheduler, it will be ignored for other schedulers.
           # eta corresponds to η in DDIM paper: https://arxiv.org/abs/2010.02502
           # and should be between [0, 1]
           SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		'''eta''' in set(inspect.signature(self.scheduler.step      ).parameters.keys()      )
           SCREAMING_SNAKE_CASE__       :  Any						     =		{}
           if accepts_eta:
                 SCREAMING_SNAKE_CASE__       :  Union[str, Any]						     =		eta

           for i, t in enumerate(self.progress_bar(_lowercase      )      ):
                 # expand the latents if we are doing classifier free guidance
                 SCREAMING_SNAKE_CASE__       :  Dict						     =		torch.cat([latents] * 2      ) if do_classifier_free_guidance else latents
                 SCREAMING_SNAKE_CASE__       :  str						     =		self.scheduler.scale_model_input(_lowercase   ,   _lowercase      )

                 # predict the noise residual
                 SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		self.unet(_lowercase   ,   _lowercase   ,   encoder_hidden_states=_lowercase      ).sample

                 # perform guidance
                 if do_classifier_free_guidance:
                       SCREAMING_SNAKE_CASE__     ,       SCREAMING_SNAKE_CASE__       :  List[Any]						     =		noise_pred.chunk(2      )
                       SCREAMING_SNAKE_CASE__       :  str						     =		noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)

                 # compute the previous noisy sample x_t -> x_t-1
                 SCREAMING_SNAKE_CASE__       :  List[Any]						     =		self.scheduler.step(_lowercase   ,   _lowercase   ,   _lowercase   ,   **_lowercase      ).prev_sample

                 # call the callback, if provided
                 if callback is not None and i % callback_steps == 0:
                       callback(_lowercase   ,   _lowercase   ,   _lowercase      )

           SCREAMING_SNAKE_CASE__       :  Dict						     =		1 / 0.18215 * latents
           SCREAMING_SNAKE_CASE__       :  Dict						     =		self.vae.decode(_lowercase      ).sample

           SCREAMING_SNAKE_CASE__       :  List[Any]						     =		(image / 2 + 0.5).clamp(0   ,   1      )

           # we always cast to float32 as this does not cause significant overhead and is compatible with bfloat16
           SCREAMING_SNAKE_CASE__       :  int						     =		image.cpu().permute(0   ,   2   ,   3   ,   1      ).float().numpy()

           if self.safety_checker is not None:
                 SCREAMING_SNAKE_CASE__       :  Any						     =		self.feature_extractor(self.numpy_to_pil(_lowercase      )   ,   return_tensors='''pt'''      ).to(
                     self.device      )
                 SCREAMING_SNAKE_CASE__     ,       SCREAMING_SNAKE_CASE__       :  Any						     =		self.safety_checker(
                     images=_lowercase   ,   clip_input=safety_checker_input.pixel_values.to(text_embeddings.dtype      )      )
           else:
                 SCREAMING_SNAKE_CASE__       :  Optional[int]						     =		None

           if output_type == "pil":
                 SCREAMING_SNAKE_CASE__       :  int						     =		self.numpy_to_pil(_lowercase      )

           if not return_dict:
                 return (image, has_nsfw_concept)

           return StableDiffusionPipelineOutput(images=_lowercase   ,   nsfw_content_detected=_lowercase      )













import warnings
from typing import Any, Dict, List, Optional, Union

import numpy as np

from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function
from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


SCREAMING_SNAKE_CASE__							:      Optional[int]         =    logging.get_logger(__name__)







class 	__lowerCAmelCase      (       _UpperCamelCase	):
   _UpperCamelCase			:    Tuple  		=					["""input_values""", """attention_mask"""]





   def __init__(			self       ,      snake_case = 1       ,      snake_case = 16_000       ,      snake_case = 0.0       ,      snake_case = False       ,      snake_case = 80       ,      snake_case = 16       ,      snake_case = 64       ,      snake_case = "hann_window"       ,      snake_case = 1.0       ,      snake_case = 80       ,      snake_case = 7_600       ,      snake_case = 1E-10       ,      snake_case = 2       ,      snake_case = True       ,      **snake_case       ,      )					->	Dict:
      """simple docstring"""





      super().__init__(feature_size=snake_case       ,      sampling_rate=snake_case       ,      padding_value=snake_case       ,      **snake_case   )
      a__						:    Any   		=	do_normalize
      a__						:    List[str]   		=	return_attention_mask

      a__						:    List[Any]   		=	num_mel_bins
      a__						:    List[str]   		=	hop_length
      a__						:    int   		=	win_length
      a__						:    List[Any]   		=	win_function
      a__						:    List[str]   		=	frame_signal_scale
      a__						:    List[Any]   		=	fmin
      a__						:    Optional[Any]   		=	fmax
      a__						:    Union[str, Any]   		=	mel_floor
      a__						:    Union[str, Any]   		=	reduction_factor

      a__						:    List[str]   		=	win_length * sampling_rate // 1_000
      a__						:    List[Any]   		=	hop_length * sampling_rate // 1_000
      a__						:    List[Any]   		=	optimal_fft_length(self.sample_size   )
      a__						:    Dict   		=	(self.n_fft // 2) + 1

      a__						:    str   		=	window_function(window_length=self.sample_size       ,      name=self.win_function       ,      periodic=snake_case   )

      a__						:    Tuple   		=	mel_filter_bank(
          num_frequency_bins=self.n_freqs       ,      num_mel_filters=self.num_mel_bins       ,      min_frequency=self.fmin       ,      max_frequency=self.fmax       ,      sampling_rate=self.sampling_rate       ,      norm="slaney"       ,      mel_scale="slaney"       ,      )

      if frame_signal_scale != 1.0:
         warnings.warn(
             "The argument `frame_signal_scale` is deprecated and will be removed in version 4.30.0 of Transformers"       ,      snake_case       ,      )
      if reduction_factor != 2.0:
         warnings.warn(
             "The argument `reduction_factor` is deprecated and will be removed in version 4.30.0 of Transformers"       ,      snake_case       ,      )





   @staticmethod
   # Copied from transformers.models.wav2vec2.feature_extraction_wav2vec2.Wav2Vec2FeatureExtractor.zero_mean_unit_var_norm
   def 						_snake_case			(			snake_case       ,      snake_case       ,      snake_case = 0.0   )					->	List[np.ndarray]:
      """simple docstring"""





      if attention_mask is not None:
         a__						:    Tuple   		=	np.array(snake_case       ,      np.intaa   )
         a__						:    List[str]   		=	[]

         for vector, length in zip(snake_case       ,      attention_mask.sum(-1   )   ):
            a__						:    List[Any]   		=	(vector - vector[:length].mean()) / np.sqrt(vector[:length].var() + 1E-7   )
            if length < normed_slice.shape[0]:
               a__						:    List[str]   		=	padding_value

            normed_input_values.append(snake_case   )
      else:
         a__						:    Any   		=	[(x - x.mean()) / np.sqrt(x.var() + 1E-7   ) for x in input_values]

      return normed_input_values





   def 						_snake_case			(			self       ,      snake_case       ,      )					->	np.ndarray:
      """simple docstring"""





      a__						:    str   		=	spectrogram(
          snake_case       ,      window=self.window       ,      frame_length=self.sample_size       ,      hop_length=self.sample_stride       ,      fft_length=self.n_fft       ,      mel_filters=self.mel_filters       ,      mel_floor=self.mel_floor       ,      log_mel="log10"       ,      )
      return log_mel_spec.T





   def __call__(			self       ,      snake_case = None       ,      snake_case = None       ,      snake_case = False       ,      snake_case = None       ,      snake_case = False       ,      snake_case = None       ,      snake_case = None       ,      snake_case = None       ,      snake_case = None       ,      **snake_case       ,      )					->	BatchFeature:
      """simple docstring"""





      if audio is None and audio_target is None:
         raise ValueError("You must provide either `audio` or `audio_target` values."   )

      if sampling_rate is not None:
         if sampling_rate != self.sampling_rate:
            raise ValueError(
                F"""The model corresponding to this feature extractor: {self} was trained using a sampling rate of"""
                F""" {self.sampling_rate}. Please make sure that the provided audio input was sampled with"""
                F""" {self.sampling_rate} and not {sampling_rate}."""   )
      else:
         logger.warning(
             "It is strongly recommended to pass the ``sampling_rate`` argument to this function. "
             "Failing to do so can result in silent errors that might be hard to debug."   )

      if audio is not None:
         a__						:    Dict   		=	self._process_audio(
             snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      **snake_case       ,      )
      else:
         a__						:    Optional[int]   		=	None

      if audio_target is not None:
         a__						:    List[Any]   		=	self._process_audio(
             snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      snake_case       ,      **snake_case       ,      )

         if inputs is None:
            return inputs_target
         else:
            a__						:    Tuple   		=	inputs_target["input_values"]
            a__						:    Tuple   		=	inputs_target.get("attention_mask"   )
            if decoder_attention_mask is not None:
               a__						:    Tuple   		=	decoder_attention_mask

      return inputs





   def 						_snake_case			(			self       ,      snake_case       ,      snake_case = False       ,      snake_case = False       ,      snake_case = None       ,      snake_case = False       ,      snake_case = None       ,      snake_case = None       ,      snake_case = None       ,      **snake_case       ,      )					->	BatchFeature:
      """simple docstring"""





      a__						:    Optional[int]   		=	isinstance(snake_case       ,      np.ndarray   ) and len(speech.shape   ) > 1
      if is_batched_numpy and len(speech.shape   ) > 2:
         raise ValueError(F"""Only mono-channel audio is supported for input to {self}"""   )
      a__						:    List[Any]   		=	is_batched_numpy or (
          isinstance(snake_case       ,      (list, tuple)   ) and (isinstance(speech[0]       ,      (np.ndarray, tuple, list)   ))
      )

      if is_batched:
         a__						:    int   		=	[np.asarray(snake_case       ,      dtype=np.floataa   ) for speech in speech]
      elif not is_batched and not isinstance(snake_case       ,      np.ndarray   ):
         a__						:    Any   		=	np.asarray(snake_case       ,      dtype=np.floataa   )
      elif isinstance(snake_case       ,      np.ndarray   ) and speech.dtype is np.dtype(np.floataa   ):
         a__						:    List[Any]   		=	speech.astype(np.floataa   )

      # always return batch
      if not is_batched:
         a__						:    Union[str, Any]   		=	[speech]

      # needed to make pad() work on spectrogram inputs
      a__						:    Optional[Any]   		=	self.feature_size

      # convert into correct format for padding
      if is_target:
         a__						:    List[str]   		=	[self._extract_mel_features(snake_case   ) for waveform in speech]
         a__						:    Optional[Any]   		=	BatchFeature({"input_values": features}   )
         a__						:    str   		=	self.num_mel_bins
      else:
         a__						:    int   		=	BatchFeature({"input_values": speech}   )

      a__						:    int   		=	self.pad(
          snake_case       ,      padding=snake_case       ,      max_length=snake_case       ,      truncation=snake_case       ,      pad_to_multiple_of=snake_case       ,      return_attention_mask=snake_case       ,      **snake_case       ,      )

      a__						:    Any   		=	feature_size_hack

      # convert input values to correct format
      a__						:    Tuple   		=	padded_inputs["input_values"]
      if not isinstance(input_values[0]       ,      np.ndarray   ):
         a__						:    int   		=	[np.asarray(snake_case       ,      dtype=np.floataa   ) for array in input_values]
      elif (
          not isinstance(snake_case       ,      np.ndarray   )
          and isinstance(input_values[0]       ,      np.ndarray   )
          and input_values[0].dtype is np.dtype(np.floataa   )
      ):
         a__						:    Union[str, Any]   		=	[array.astype(np.floataa   ) for array in input_values]
      elif isinstance(snake_case       ,      np.ndarray   ) and input_values.dtype is np.dtype(np.floataa   ):
         a__						:    Optional[int]   		=	input_values.astype(np.floataa   )

      # convert attention_mask to correct format
      a__						:    Optional[int]   		=	padded_inputs.get("attention_mask"   )
      if attention_mask is not None:
         a__						:    Tuple   		=	[np.asarray(snake_case       ,      dtype=np.intaa   ) for array in attention_mask]

      # zero-mean and unit-variance normalization
      if not is_target and self.do_normalize:
         a__						:    Any   		=	(
             attention_mask
             if self._get_padding_strategies(snake_case       ,      max_length=snake_case   ) is not PaddingStrategy.DO_NOT_PAD
             else None
         )
         a__						:    Optional[Any]   		=	self.zero_mean_unit_var_norm(
             padded_inputs["input_values"]       ,      attention_mask=snake_case       ,      padding_value=self.padding_value   )

      if return_tensors is not None:
         a__						:    int   		=	padded_inputs.convert_to_tensors(snake_case   )

      return padded_inputs





   def 						_snake_case			(			self   )					->	Dict[str, Any]:
      """simple docstring"""





      a__						:    int   		=	super().to_dict()

      # Don't serialize these as they are derived from the other properties.
      a__						:    str   		=	["window", "mel_filters", "sample_size", "sample_stride", "n_fft", "n_freqs"]
      for name in names:
         if name in output:
            del output[name]

      return output

