



"""simple docstring"""






import gc
import random
import unittest

import numpy as np
import torch
from transformers import (
    CLIPImageProcessor,
    CLIPTextConfig,
    CLIPTextModelWithProjection,
    CLIPTokenizer,
    CLIPVisionConfig,
    CLIPVisionModelWithProjection,
)

from diffusers import (
    DiffusionPipeline,
    UnCLIPImageVariationPipeline,
    UnCLIPScheduler,
    UNetaDConditionModel,
    UNetaDModel,
)
from diffusers.pipelines.unclip.text_proj import UnCLIPTextProjModel
from diffusers.utils import floats_tensor, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, load_image, require_torch_gpu, skip_mps

from ..pipeline_params import IMAGE_VARIATION_BATCH_PARAMS, IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference


enable_full_determinism()







class 	__SCREAMING_SNAKE_CASE     (				lowerCAmelCase_		,       unittest.TestCase       ):


					'''simple docstring'''





					_a             =							UnCLIPImageVariationPipeline
					_a             =							IMAGE_VARIATION_PARAMS - {'height', 'width', 'guidance_scale'}
					_a             =							IMAGE_VARIATION_BATCH_PARAMS

					_a             =							[
					    'generator',
					    'return_dict',
					    'decoder_num_inference_steps',
					    'super_res_num_inference_steps',
					]
					_a             =							False



					@property
					def 		snake_case	(	self							:  Optional[Any]					)-> List[Any]:
								return 32



					@property
					def 		snake_case	(	self							:  int					)-> Tuple:
								return 32



					@property
					def 		snake_case	(	self							:  str					)-> str:
								return self.time_input_dim



					@property
					def 		snake_case	(	self							:  Optional[int]					)-> Any:
								return self.time_input_dim * 4



					@property
					def 		snake_case	(	self							:  Union[str, Any]					)-> Tuple:
								return 100



					@property
					def 		snake_case	(	self							:  List[str]					)-> str:
								lowerCamelCase__		:		Optional[Any]		     =CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''					)
								return tokenizer



					@property
					def 		snake_case	(	self							:  Optional[int]					)-> Union[str, Any]:
								torch.manual_seed(0					)
								lowerCamelCase__		:		Dict		     =CLIPTextConfig(
								    bos_token_id=0,  eos_token_id=2,  hidden_size=self.text_embedder_hidden_size,  projection_dim=self.text_embedder_hidden_size,  intermediate_size=37,  layer_norm_eps=1E-05,  num_attention_heads=4,  num_hidden_layers=5,  pad_token_id=1,  vocab_size=1000,  )
								return CLIPTextModelWithProjection(lowerCamelCase					)



					@property
					def 		snake_case	(	self							:  List[Any]					)-> int:
								torch.manual_seed(0					)
								lowerCamelCase__		:		Optional[Any]		     =CLIPVisionConfig(
								    hidden_size=self.text_embedder_hidden_size,  projection_dim=self.text_embedder_hidden_size,  num_hidden_layers=5,  num_attention_heads=4,  image_size=32,  intermediate_size=37,  patch_size=1,  )
								return CLIPVisionModelWithProjection(lowerCamelCase					)



					@property
					def 		snake_case	(	self							:  Dict					)-> Tuple:
								torch.manual_seed(0					)

								lowerCamelCase__		:		Optional[int]		     ={
								    '''clip_embeddings_dim''': self.text_embedder_hidden_size,
								    '''time_embed_dim''': self.time_embed_dim,
								    '''cross_attention_dim''': self.cross_attention_dim,
								}

								lowerCamelCase__		:		Tuple		     =UnCLIPTextProjModel(**lowerCamelCase					)
								return model



					@property
					def 		snake_case	(	self							:  Optional[int]					)-> Dict:
								torch.manual_seed(0					)

								lowerCamelCase__		:		Any		     ={
								    '''sample_size''': 32,
								    # RGB in channels
								    '''in_channels''': 3,
								    # Out channels is double in channels because predicts mean and variance
								    '''out_channels''': 6,
								    '''down_block_types''': ('''ResnetDownsampleBlock2D''', '''SimpleCrossAttnDownBlock2D'''),
								    '''up_block_types''': ('''SimpleCrossAttnUpBlock2D''', '''ResnetUpsampleBlock2D'''),
								    '''mid_block_type''': '''UNetMidBlock2DSimpleCrossAttn''',
								    '''block_out_channels''': (self.block_out_channels_a, self.block_out_channels_a * 2),
								    '''layers_per_block''': 1,
								    '''cross_attention_dim''': self.cross_attention_dim,
								    '''attention_head_dim''': 4,
								    '''resnet_time_scale_shift''': '''scale_shift''',
								    '''class_embed_type''': '''identity''',
								}

								lowerCamelCase__		:		str		     =UNetaDConditionModel(**lowerCamelCase					)
								return model



					@property
					def 		snake_case	(	self							:  Optional[Any]					)-> List[str]:
								return {
								    "sample_size": 64,
								    "layers_per_block": 1,
								    "down_block_types": ("ResnetDownsampleBlock2D", "ResnetDownsampleBlock2D"),
								    "up_block_types": ("ResnetUpsampleBlock2D", "ResnetUpsampleBlock2D"),
								    "block_out_channels": (self.block_out_channels_a, self.block_out_channels_a * 2),
								    "in_channels": 6,
								    "out_channels": 3,
								}



					@property
					def 		snake_case	(	self							:  int					)-> Dict:
								torch.manual_seed(0					)

								lowerCamelCase__		:		List[Any]		     =UNetaDModel(**self.dummy_super_res_kwargs					)
								return model



					@property
					def 		snake_case	(	self							:  Any					)-> Any:
								# seeded differently to get different unet than `self.dummy_super_res_first`
								torch.manual_seed(1					)

								lowerCamelCase__		:		str		     =UNetaDModel(**self.dummy_super_res_kwargs					)
								return model



					def 		snake_case	(	self							:  List[Any]					)-> Optional[Any]:
								lowerCamelCase__		:		List[str]		     =self.dummy_decoder
								lowerCamelCase__		:		Union[str, Any]		     =self.dummy_text_proj
								lowerCamelCase__		:		Any		     =self.dummy_text_encoder
								lowerCamelCase__		:		Union[str, Any]		     =self.dummy_tokenizer
								lowerCamelCase__		:		Optional[Any]		     =self.dummy_super_res_first
								lowerCamelCase__		:		Optional[int]		     =self.dummy_super_res_last

								lowerCamelCase__		:		Optional[int]		     =UnCLIPScheduler(
								    variance_type='''learned_range''',  prediction_type='''epsilon''',  num_train_timesteps=1000,  )

								lowerCamelCase__		:		Dict		     =UnCLIPScheduler(
								    variance_type='''fixed_small_log''',  prediction_type='''epsilon''',  num_train_timesteps=1000,  )

								lowerCamelCase__		:		Union[str, Any]		     =CLIPImageProcessor(crop_size=32,  size=32					)

								lowerCamelCase__		:		str		     =self.dummy_image_encoder

								return {
								    "decoder": decoder,
								    "text_encoder": text_encoder,
								    "tokenizer": tokenizer,
								    "text_proj": text_proj,
								    "feature_extractor": feature_extractor,
								    "image_encoder": image_encoder,
								    "super_res_first": super_res_first,
								    "super_res_last": super_res_last,
								    "decoder_scheduler": decoder_scheduler,
								    "super_res_scheduler": super_res_scheduler,
								}



					def 		snake_case	(	self							:  int,  lowerCamelCase							:  str,  lowerCamelCase							:  Union[str, Any]=0,  lowerCamelCase							:  Dict=True					)-> Optional[int]:
								lowerCamelCase__		:		List[str]		     =floats_tensor((1, 3, 32, 32),  rng=random.Random(lowerCamelCase					)					).to(lowerCamelCase					)
								if str(lowerCamelCase					).startswith('''mps'''					):
											lowerCamelCase__		:		Optional[Any]		     =torch.manual_seed(lowerCamelCase					)
								else:
											lowerCamelCase__		:		Optional[int]		     =torch.Generator(device=lowerCamelCase					).manual_seed(lowerCamelCase					)

								if pil_image:
											lowerCamelCase__		:		Tuple		     =input_image * 0.5 + 0.5
											lowerCamelCase__		:		Optional[int]		     =input_image.clamp(0,  1					)
											lowerCamelCase__		:		Tuple		     =input_image.cpu().permute(0,  2,  3,  1					).float().numpy()
											lowerCamelCase__		:		Tuple		     =DiffusionPipeline.numpy_to_pil(lowerCamelCase					)[0]

								return {
								    "image": input_image,
								    "generator": generator,
								    "decoder_num_inference_steps": 2,
								    "super_res_num_inference_steps": 2,
								    "output_type": "np",
								}



					def 		snake_case	(	self							:  str					)-> Optional[int]:
								lowerCamelCase__		:		Dict		     ='''cpu'''

								lowerCamelCase__		:		List[str]		     =self.get_dummy_components()

								lowerCamelCase__		:		Union[str, Any]		     =self.pipeline_class(**lowerCamelCase					)
								lowerCamelCase__		:		Optional[int]		     =pipe.to(lowerCamelCase					)

								pipe.set_progress_bar_config(disable=lowerCamelCase					)

								lowerCamelCase__		:		Optional[int]		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)

								lowerCamelCase__		:		str		     =pipe(**lowerCamelCase					)
								lowerCamelCase__		:		Union[str, Any]		     =output.images

								lowerCamelCase__		:		List[Any]		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)

								lowerCamelCase__		:		Dict		     =pipe(
								    **lowerCamelCase,  return_dict=lowerCamelCase,  )[0]

								lowerCamelCase__		:		Union[str, Any]		     =image[0, -3:, -3:, -1]
								lowerCamelCase__		:		Dict		     =image_from_tuple[0, -3:, -3:, -1]

								assert image.shape == (1, 64, 64, 3)

								lowerCamelCase__		:		Dict		     =np.array(
								    [
								        0.9_997,
								        0.0_002,
								        0.9_997,
								        0.9_997,
								        0.9_969,
								        0.0_023,
								        0.9_997,
								        0.9_969,
								        0.9_970,
								    ]					)

								assert np.abs(image_slice.flatten() - expected_slice					).max() < 1E-2
								assert np.abs(image_from_tuple_slice.flatten() - expected_slice					).max() < 1E-2



					def 		snake_case	(	self							:  Union[str, Any]					)-> Optional[Any]:
								lowerCamelCase__		:		Union[str, Any]		     ='''cpu'''

								lowerCamelCase__		:		Any		     =self.get_dummy_components()

								lowerCamelCase__		:		Dict		     =self.pipeline_class(**lowerCamelCase					)
								lowerCamelCase__		:		Optional[int]		     =pipe.to(lowerCamelCase					)

								pipe.set_progress_bar_config(disable=lowerCamelCase					)

								lowerCamelCase__		:		Tuple		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)

								lowerCamelCase__		:		Dict		     =pipe(**lowerCamelCase					)
								lowerCamelCase__		:		Tuple		     =output.images

								lowerCamelCase__		:		Any		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)

								lowerCamelCase__		:		int		     =pipe(
								    **lowerCamelCase,  return_dict=lowerCamelCase,  )[0]

								lowerCamelCase__		:		str		     =image[0, -3:, -3:, -1]
								lowerCamelCase__		:		List[Any]		     =image_from_tuple[0, -3:, -3:, -1]

								assert image.shape == (1, 64, 64, 3)

								lowerCamelCase__		:		str		     =np.array([0.9_997, 0.0_003, 0.9_997, 0.9_997, 0.9_970, 0.0_024, 0.9_997, 0.9_971, 0.9_971]					)

								assert np.abs(image_slice.flatten() - expected_slice					).max() < 1E-2
								assert np.abs(image_from_tuple_slice.flatten() - expected_slice					).max() < 1E-2



					def 		snake_case	(	self							:  str					)-> Optional[Any]:
								lowerCamelCase__		:		Union[str, Any]		     ='''cpu'''

								lowerCamelCase__		:		str		     =self.get_dummy_components()

								lowerCamelCase__		:		Tuple		     =self.pipeline_class(**lowerCamelCase					)
								lowerCamelCase__		:		Union[str, Any]		     =pipe.to(lowerCamelCase					)

								pipe.set_progress_bar_config(disable=lowerCamelCase					)

								lowerCamelCase__		:		Any		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)
								lowerCamelCase__		:		Union[str, Any]		     =[
								    pipeline_inputs['''image'''],
								    pipeline_inputs['''image'''],
								]

								lowerCamelCase__		:		Tuple		     =pipe(**lowerCamelCase					)
								lowerCamelCase__		:		Union[str, Any]		     =output.images

								lowerCamelCase__		:		Tuple		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)
								lowerCamelCase__		:		Tuple		     =[
								    tuple_pipeline_inputs['''image'''],
								    tuple_pipeline_inputs['''image'''],
								]

								lowerCamelCase__		:		List[str]		     =pipe(
								    **lowerCamelCase,  return_dict=lowerCamelCase,  )[0]

								lowerCamelCase__		:		Union[str, Any]		     =image[0, -3:, -3:, -1]
								lowerCamelCase__		:		List[str]		     =image_from_tuple[0, -3:, -3:, -1]

								assert image.shape == (2, 64, 64, 3)

								lowerCamelCase__		:		str		     =np.array(
								    [
								        0.9_997,
								        0.9_989,
								        0.0_008,
								        0.0_021,
								        0.9_960,
								        0.0_018,
								        0.0_014,
								        0.0_002,
								        0.9_933,
								    ]					)

								assert np.abs(image_slice.flatten() - expected_slice					).max() < 1E-2
								assert np.abs(image_from_tuple_slice.flatten() - expected_slice					).max() < 1E-2



					def 		snake_case	(	self							:  str					)-> List[str]:
								lowerCamelCase__		:		Optional[int]		     =torch.device('''cpu'''					)







								class 	__SCREAMING_SNAKE_CASE     :


													'''simple docstring'''





													_a             =							1





								lowerCamelCase__		:		Tuple		     =self.get_dummy_components()

								lowerCamelCase__		:		Optional[int]		     =self.pipeline_class(**lowerCamelCase					)
								lowerCamelCase__		:		Dict		     =pipe.to(lowerCamelCase					)

								pipe.set_progress_bar_config(disable=lowerCamelCase					)

								lowerCamelCase__		:		str		     =torch.Generator(device=lowerCamelCase					).manual_seed(0					)
								lowerCamelCase__		:		Any		     =pipe.decoder.dtype
								lowerCamelCase__		:		Optional[Any]		     =1

								lowerCamelCase__		:		Any		     =(
								    batch_size,
								    pipe.decoder.config.in_channels,
								    pipe.decoder.config.sample_size,
								    pipe.decoder.config.sample_size,
								)
								lowerCamelCase__		:		Dict		     =pipe.prepare_latents(
								    lowerCamelCase,  dtype=lowerCamelCase,  device=lowerCamelCase,  generator=lowerCamelCase,  latents=lowerCamelCase,  scheduler=DummyScheduler()					)

								lowerCamelCase__		:		List[Any]		     =(
								    batch_size,
								    pipe.super_res_first.config.in_channels // 2,
								    pipe.super_res_first.config.sample_size,
								    pipe.super_res_first.config.sample_size,
								)
								lowerCamelCase__		:		Optional[Any]		     =pipe.prepare_latents(
								    lowerCamelCase,  dtype=lowerCamelCase,  device=lowerCamelCase,  generator=lowerCamelCase,  latents=lowerCamelCase,  scheduler=DummyScheduler()					)

								lowerCamelCase__		:		int		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)

								lowerCamelCase__		:		Tuple		     =pipe(
								    **lowerCamelCase,  decoder_latents=lowerCamelCase,  super_res_latents=lowerCamelCase					).images

								lowerCamelCase__		:		int		     =self.get_dummy_inputs(lowerCamelCase,  pil_image=lowerCamelCase					)
								# Don't pass image, instead pass embedding
								lowerCamelCase__		:		Dict		     =pipeline_inputs.pop('''image'''					)
								lowerCamelCase__		:		List[str]		     =pipe.image_encoder(lowerCamelCase					).image_embeds

								lowerCamelCase__		:		Any		     =pipe(
								    **lowerCamelCase,  decoder_latents=lowerCamelCase,  super_res_latents=lowerCamelCase,  image_embeddings=lowerCamelCase,  ).images

								# make sure passing text embeddings manually is identical
								assert np.abs(img_out_a - img_out_a					).max() < 1E-4



					@skip_mps
					def 		snake_case	(	self							:  Optional[int]					)-> List[Any]:
								lowerCamelCase__		:		Dict		     =torch_device == '''cpu'''

								# Check is relaxed because there is not a torch 2.0 sliced attention added kv processor
								lowerCamelCase__		:		Dict		     =1E-2

								self._test_attention_slicing_forward_pass(
								    test_max_difference=lowerCamelCase,  expected_max_diff=lowerCamelCase					)



					@skip_mps
					def 		snake_case	(	self							:  str					)-> Optional[int]:
								lowerCamelCase__		:		Dict		     =torch_device == '''cpu'''
								lowerCamelCase__		:		Dict		     =True
								lowerCamelCase__		:		int		     =[
								    '''decoder_num_inference_steps''',
								    '''super_res_num_inference_steps''',
								]

								self._test_inference_batch_single_identical(
								    test_max_difference=lowerCamelCase,  relax_max_difference=lowerCamelCase,  additional_params_copy_to_batched_inputs=lowerCamelCase,  )



					def 		snake_case	(	self							:  Optional[int]					)-> str:
								lowerCamelCase__		:		List[str]		     =[
								    '''decoder_num_inference_steps''',
								    '''super_res_num_inference_steps''',
								]

								if torch_device == "mps":
											# TODO: MPS errors with larger batch sizes
											lowerCamelCase__		:		Union[str, Any]		     =[2, 3]
											self._test_inference_batch_consistent(
											    batch_sizes=lowerCamelCase,  additional_params_copy_to_batched_inputs=lowerCamelCase,  )
								else:
											self._test_inference_batch_consistent(
											    additional_params_copy_to_batched_inputs=lowerCamelCase					)



					@skip_mps
					def 		snake_case	(	self							:  Tuple					)-> Optional[Any]:
								return super().test_dict_tuple_outputs_equivalent()



					@skip_mps
					def 		snake_case	(	self							:  List[str]					)-> Optional[int]:
								return super().test_save_load_local()




					@skip_mps
					def 		snake_case	(	self							:  Tuple					)-> str:
								return super().test_save_load_optional_components()







@slow
@require_torch_gpu
class 	__SCREAMING_SNAKE_CASE     (				unittest.TestCase       ):


					'''simple docstring'''





					def 		snake_case	(	self							:  str					)-> str:
								# clean up the VRAM after each test
								super().tearDown()
								gc.collect()
								torch.cuda.empty_cache()




					def 		snake_case	(	self							:  str					)-> Dict:
								lowerCamelCase__		:		List[str]		     =load_image(
								    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/unclip/cat.png'''					)
								lowerCamelCase__		:		Optional[int]		     =load_numpy(
								    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
								    '''/unclip/karlo_v1_alpha_cat_variation_fp16.npy'''					)

								lowerCamelCase__		:		Tuple		     =UnCLIPImageVariationPipeline.from_pretrained(
								    '''kakaobrain/karlo-v1-alpha-image-variations''',  torch_dtype=torch.floataa					)
								lowerCamelCase__		:		Tuple		     =pipeline.to(lowerCamelCase					)
								pipeline.set_progress_bar_config(disable=lowerCamelCase					)

								lowerCamelCase__		:		int		     =torch.Generator(device='''cpu'''					).manual_seed(0					)
								lowerCamelCase__		:		int		     =pipeline(
								    lowerCamelCase,  generator=lowerCamelCase,  output_type='''np''',  )

								lowerCamelCase__		:		List[str]		     =output.images[0]

								assert image.shape == (256, 256, 3)

								assert_mean_pixel_difference(lowerCamelCase,  lowerCamelCase,  15					)









"""simple docstring"""






from ...processing_utils import ProcessorMixin

class 	__SCREAMING_SNAKE_CASE     (				lowerCAmelCase_       ):


					'''simple docstring'''





					_a             =							'SpeechT5FeatureExtractor'
					_a             =							'SpeechT5Tokenizer'



					def __init__(	self							:  Dict,  lowerCamelCase							:  Optional[int],  lowerCamelCase							:  str					)-> Any:
								super().__init__(lowerCamelCase,  lowerCamelCase					)



					def __call__(	self							:  Tuple,  *lowerCamelCase							:  List[str],  **lowerCamelCase							:  Optional[int]					)-> List[str]:
								lowerCamelCase__		:		List[Any]		     =kwargs.pop('''audio''',  lowerCamelCase					)
								lowerCamelCase__		:		List[str]		     =kwargs.pop('''text''',  lowerCamelCase					)
								lowerCamelCase__		:		int		     =kwargs.pop('''text_target''',  lowerCamelCase					)
								lowerCamelCase__		:		Dict		     =kwargs.pop('''audio_target''',  lowerCamelCase					)
								lowerCamelCase__		:		Any		     =kwargs.pop('''sampling_rate''',  lowerCamelCase					)

								if audio is not None and text is not None:
											raise ValueError(
											    '''Cannot process both `audio` and `text` inputs. Did you mean `audio_target` or `text_target`?'''					)
								if audio_target is not None and text_target is not None:
											raise ValueError(
											    '''Cannot process both `audio_target` and `text_target` inputs. Did you mean `audio` or `text`?'''					)
								if audio is None and audio_target is None and text is None and text_target is None:
											raise ValueError(
											    '''You need to specify either an `audio`, `audio_target`, `text`, or `text_target` input to process.'''					)

								if audio is not None:
											lowerCamelCase__		:		Union[str, Any]		     =self.feature_extractor(lowerCamelCase,  *lowerCamelCase,  sampling_rate=lowerCamelCase,  **lowerCamelCase					)
								elif text is not None:
											lowerCamelCase__		:		List[Any]		     =self.tokenizer(lowerCamelCase,  **lowerCamelCase					)
								else:
											lowerCamelCase__		:		Any		     =None

								if audio_target is not None:
											lowerCamelCase__		:		List[str]		     =self.feature_extractor(audio_target=lowerCamelCase,  *lowerCamelCase,  sampling_rate=lowerCamelCase,  **lowerCamelCase					)
											lowerCamelCase__		:		Tuple		     =targets['''input_values''']
								elif text_target is not None:
											lowerCamelCase__		:		Dict		     =self.tokenizer(lowerCamelCase,  **lowerCamelCase					)
											lowerCamelCase__		:		int		     =targets['''input_ids''']
								else:
											lowerCamelCase__		:		List[str]		     =None

								if inputs is None:
											return targets

								if targets is not None:
											lowerCamelCase__		:		Dict		     =labels

											lowerCamelCase__		:		Any		     =targets.get('''attention_mask'''					)
											if decoder_attention_mask is not None:
														lowerCamelCase__		:		Dict		     =decoder_attention_mask

								return inputs



					def 		snake_case	(	self							:  int,  *lowerCamelCase							:  Optional[Any],  **lowerCamelCase							:  Optional[int]					)-> Optional[Any]:
								lowerCamelCase__		:		List[Any]		     =kwargs.pop('''input_values''',  lowerCamelCase					)
								lowerCamelCase__		:		Union[str, Any]		     =kwargs.pop('''input_ids''',  lowerCamelCase					)
								lowerCamelCase__		:		Optional[Any]		     =kwargs.pop('''labels''',  lowerCamelCase					)

								if input_values is not None and input_ids is not None:
											raise ValueError('''Cannot process both `input_values` and `input_ids` inputs.'''					)
								if input_values is None and input_ids is None and labels is None:
											raise ValueError(
											    '''You need to specify either an `input_values`, `input_ids`, or `labels` input to be padded.'''					)

								if input_values is not None:
											lowerCamelCase__		:		List[str]		     =self.feature_extractor.pad(lowerCamelCase,  *lowerCamelCase,  **lowerCamelCase					)
								elif input_ids is not None:
											lowerCamelCase__		:		Tuple		     =self.tokenizer.pad(lowerCamelCase,  **lowerCamelCase					)
								else:
											lowerCamelCase__		:		Any		     =None

								if labels is not None:
											if "input_ids" in labels or (isinstance(lowerCamelCase,  lowerCamelCase					) and "input_ids" in labels[0]):
														lowerCamelCase__		:		str		     =self.tokenizer.pad(lowerCamelCase,  **lowerCamelCase					)
														lowerCamelCase__		:		List[Any]		     =targets['''input_ids''']
											else:
														lowerCamelCase__		:		Any		     =self.feature_extractor.feature_size
														lowerCamelCase__		:		Optional[Any]		     =self.feature_extractor.num_mel_bins
														lowerCamelCase__		:		Optional[int]		     =self.feature_extractor.pad(lowerCamelCase,  *lowerCamelCase,  **lowerCamelCase					)
														lowerCamelCase__		:		List[Any]		     =feature_size_hack
														lowerCamelCase__		:		Tuple		     =targets['''input_values''']
								else:
											lowerCamelCase__		:		Optional[Any]		     =None

								if inputs is None:
											return targets

								if targets is not None:
											lowerCamelCase__		:		Tuple		     =labels

											lowerCamelCase__		:		Optional[int]		     =targets.get('''attention_mask'''					)
											if decoder_attention_mask is not None:
														lowerCamelCase__		:		Optional[Any]		     =decoder_attention_mask

								return inputs



					def 		snake_case	(	self							:  List[str],  *lowerCamelCase							:  Union[str, Any],  **lowerCamelCase							:  List[Any]					)-> List[Any]:
								return self.tokenizer.batch_decode(*lowerCamelCase,  **lowerCamelCase					)




					def 		snake_case	(	self							:  List[str],  *lowerCamelCase							:  List[Any],  **lowerCamelCase							:  Tuple					)-> int:
								return self.tokenizer.decode(*lowerCamelCase,  **lowerCamelCase					)




