
"""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_					(		a_	,							unittest.TestCase					):




		"""simple docstring"""





		__lowercase				:    Any		  =						UnCLIPImageVariationPipeline
		__lowercase				:    Optional[int]		  =						IMAGE_VARIATION_PARAMS - {'''height''', '''width''', '''guidance_scale'''}
		__lowercase				:    List[Any]		  =						IMAGE_VARIATION_BATCH_PARAMS

		__lowercase				:    Dict		  =						[
		    '''generator''',
		    '''return_dict''',
		    '''decoder_num_inference_steps''',
		    '''super_res_num_inference_steps''',
		]
		__lowercase				:    List[str]		  =						False




		@property
		def       snake_case_	(	self):
				return 3_2




		@property
		def       snake_case_	(	self):
				return 3_2




		@property
		def       snake_case_	(	self):
				return self.time_input_dim




		@property
		def       snake_case_	(	self):
				return self.time_input_dim * 4




		@property
		def       snake_case_	(	self):
				return 1_0_0




		@property
		def       snake_case_	(	self):
				__SCREAMING_SNAKE_CASE				=					CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip""")
				return tokenizer




		@property
		def       snake_case_	(	self):
				torch.manual_seed(0)
				__SCREAMING_SNAKE_CASE				=					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=3_7				,    layer_norm_eps=1E-05				,    num_attention_heads=4				,    num_hidden_layers=5				,    pad_token_id=1				,    vocab_size=1_0_0_0				,    )
				return CLIPTextModelWithProjection(UpperCamelCase_)




		@property
		def       snake_case_	(	self):
				torch.manual_seed(0)
				__SCREAMING_SNAKE_CASE				=					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=3_2				,    intermediate_size=3_7				,    patch_size=1				,    )
				return CLIPVisionModelWithProjection(UpperCamelCase_)




		@property
		def       snake_case_	(	self):
				torch.manual_seed(0)

				__SCREAMING_SNAKE_CASE				=					{
				    """clip_embeddings_dim""": self.text_embedder_hidden_size,
				    """time_embed_dim""": self.time_embed_dim,
				    """cross_attention_dim""": self.cross_attention_dim,
				}

				__SCREAMING_SNAKE_CASE				=					UnCLIPTextProjModel(**UpperCamelCase_)
				return model




		@property
		def       snake_case_	(	self):
				torch.manual_seed(0)

				__SCREAMING_SNAKE_CASE				=					{
				    """sample_size""": 3_2,
				    # 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""",
				}

				__SCREAMING_SNAKE_CASE				=					UNetaDConditionModel(**UpperCamelCase_)
				return model




		@property
		def       snake_case_	(	self):
				return {
				    "sample_size": 6_4,
				    "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):
				torch.manual_seed(0)

				__SCREAMING_SNAKE_CASE				=					UNetaDModel(**self.dummy_super_res_kwargs)
				return model




		@property
		def       snake_case_	(	self):
				torch.manual_seed(1)

				__SCREAMING_SNAKE_CASE				=					UNetaDModel(**self.dummy_super_res_kwargs)
				return model




		def       snake_case_	(	self):
				__SCREAMING_SNAKE_CASE				=					self.dummy_decoder
				__SCREAMING_SNAKE_CASE				=					self.dummy_text_proj
				__SCREAMING_SNAKE_CASE				=					self.dummy_text_encoder
				__SCREAMING_SNAKE_CASE				=					self.dummy_tokenizer
				__SCREAMING_SNAKE_CASE				=					self.dummy_super_res_first
				__SCREAMING_SNAKE_CASE				=					self.dummy_super_res_last

				__SCREAMING_SNAKE_CASE				=					UnCLIPScheduler(
				    variance_type="""learned_range"""				,    prediction_type="""epsilon"""				,    num_train_timesteps=1_0_0_0				,    )

				__SCREAMING_SNAKE_CASE				=					UnCLIPScheduler(
				    variance_type="""fixed_small_log"""				,    prediction_type="""epsilon"""				,    num_train_timesteps=1_0_0_0				,    )

				__SCREAMING_SNAKE_CASE				=					CLIPImageProcessor(crop_size=3_2				,    size=3_2)

				__SCREAMING_SNAKE_CASE				=					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				,    lowerCAmelCase__				,    lowerCAmelCase__=0				,    lowerCAmelCase__=True):
				__SCREAMING_SNAKE_CASE				=					floats_tensor((1, 3, 3_2, 3_2)				,    rng=random.Random(UpperCamelCase_)).to(UpperCamelCase_)
				if str(UpperCamelCase_).startswith("""mps"""):
						__SCREAMING_SNAKE_CASE				=					torch.manual_seed(UpperCamelCase_)
				else:
						__SCREAMING_SNAKE_CASE				=					torch.Generator(device=UpperCamelCase_).manual_seed(UpperCamelCase_)

				if pil_image:
						__SCREAMING_SNAKE_CASE				=					input_image * 0.5 + 0.5
						__SCREAMING_SNAKE_CASE				=					input_image.clamp(0				,    1)
						__SCREAMING_SNAKE_CASE				=					input_image.cpu().permute(0				,    2				,    3				,    1).float().numpy()
						__SCREAMING_SNAKE_CASE				=					DiffusionPipeline.numpy_to_pil(UpperCamelCase_)[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):
				__SCREAMING_SNAKE_CASE				=					"""cpu"""

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_components()

				__SCREAMING_SNAKE_CASE				=					self.pipeline_class(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					pipe.to(UpperCamelCase_)

				pipe.set_progress_bar_config(disable=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					pipe(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					output.images

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					pipe(
				    **UpperCamelCase_				,    return_dict=UpperCamelCase_				,    )[0]

				__SCREAMING_SNAKE_CASE				=					image[0, -3:, -3:, -1]
				__SCREAMING_SNAKE_CASE				=					image_from_tuple[0, -3:, -3:, -1]

				assert image.shape == (1, 6_4, 6_4, 3)

				__SCREAMING_SNAKE_CASE				=					np.array(
				    [
				        0.99_97,
				        0.00_02,
				        0.99_97,
				        0.99_97,
				        0.99_69,
				        0.00_23,
				        0.99_97,
				        0.99_69,
				        0.99_70,
				    ])

				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):
				__SCREAMING_SNAKE_CASE				=					"""cpu"""

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_components()

				__SCREAMING_SNAKE_CASE				=					self.pipeline_class(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					pipe.to(UpperCamelCase_)

				pipe.set_progress_bar_config(disable=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					pipe(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					output.images

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					pipe(
				    **UpperCamelCase_				,    return_dict=UpperCamelCase_				,    )[0]

				__SCREAMING_SNAKE_CASE				=					image[0, -3:, -3:, -1]
				__SCREAMING_SNAKE_CASE				=					image_from_tuple[0, -3:, -3:, -1]

				assert image.shape == (1, 6_4, 6_4, 3)

				__SCREAMING_SNAKE_CASE				=					np.array([0.99_97, 0.00_03, 0.99_97, 0.99_97, 0.99_70, 0.00_24, 0.99_97, 0.99_71, 0.99_71])

				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):
				__SCREAMING_SNAKE_CASE				=					"""cpu"""

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_components()

				__SCREAMING_SNAKE_CASE				=					self.pipeline_class(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					pipe.to(UpperCamelCase_)

				pipe.set_progress_bar_config(disable=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					[
				    pipeline_inputs["""image"""],
				    pipeline_inputs["""image"""],
				]

				__SCREAMING_SNAKE_CASE				=					pipe(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					output.images

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					[
				    tuple_pipeline_inputs["""image"""],
				    tuple_pipeline_inputs["""image"""],
				]

				__SCREAMING_SNAKE_CASE				=					pipe(
				    **UpperCamelCase_				,    return_dict=UpperCamelCase_				,    )[0]

				__SCREAMING_SNAKE_CASE				=					image[0, -3:, -3:, -1]
				__SCREAMING_SNAKE_CASE				=					image_from_tuple[0, -3:, -3:, -1]

				assert image.shape == (2, 6_4, 6_4, 3)

				__SCREAMING_SNAKE_CASE				=					np.array(
				    [
				        0.99_97,
				        0.99_89,
				        0.00_08,
				        0.00_21,
				        0.99_60,
				        0.00_18,
				        0.00_14,
				        0.00_02,
				        0.99_33,
				    ])

				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):
				__SCREAMING_SNAKE_CASE				=					torch.device("""cpu""")
				class 		SCREAMING_SNAKE_CASE_					:




						"""simple docstring"""





						__lowercase				:    Tuple		  =						1



				__SCREAMING_SNAKE_CASE				=					self.get_dummy_components()

				__SCREAMING_SNAKE_CASE				=					self.pipeline_class(**UpperCamelCase_)
				__SCREAMING_SNAKE_CASE				=					pipe.to(UpperCamelCase_)

				pipe.set_progress_bar_config(disable=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					torch.Generator(device=UpperCamelCase_).manual_seed(0)
				__SCREAMING_SNAKE_CASE				=					pipe.decoder.dtype
				__SCREAMING_SNAKE_CASE				=					1

				__SCREAMING_SNAKE_CASE				=					(
				    batch_size,
				    pipe.decoder.config.in_channels,
				    pipe.decoder.config.sample_size,
				    pipe.decoder.config.sample_size,
				)
				__SCREAMING_SNAKE_CASE				=					pipe.prepare_latents(
				    UpperCamelCase_				,    dtype=UpperCamelCase_				,    device=UpperCamelCase_				,    generator=UpperCamelCase_				,    latents=UpperCamelCase_				,    scheduler=DummyScheduler())

				__SCREAMING_SNAKE_CASE				=					(
				    batch_size,
				    pipe.super_res_first.config.in_channels // 2,
				    pipe.super_res_first.config.sample_size,
				    pipe.super_res_first.config.sample_size,
				)
				__SCREAMING_SNAKE_CASE				=					pipe.prepare_latents(
				    UpperCamelCase_				,    dtype=UpperCamelCase_				,    device=UpperCamelCase_				,    generator=UpperCamelCase_				,    latents=UpperCamelCase_				,    scheduler=DummyScheduler())

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					pipe(
				    **UpperCamelCase_				,    decoder_latents=UpperCamelCase_				,    super_res_latents=UpperCamelCase_).images

				__SCREAMING_SNAKE_CASE				=					self.get_dummy_inputs(UpperCamelCase_				,    pil_image=UpperCamelCase_)
				# Don't pass image, instead pass embedding
				__SCREAMING_SNAKE_CASE				=					pipeline_inputs.pop("""image""")
				__SCREAMING_SNAKE_CASE				=					pipe.image_encoder(UpperCamelCase_).image_embeds

				__SCREAMING_SNAKE_CASE				=					pipe(
				    **UpperCamelCase_				,    decoder_latents=UpperCamelCase_				,    super_res_latents=UpperCamelCase_				,    image_embeddings=UpperCamelCase_				,    ).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):
				__SCREAMING_SNAKE_CASE				=					torch_device == """cpu"""

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

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




		@skip_mps
		def       snake_case_	(	self):
				__SCREAMING_SNAKE_CASE				=					torch_device == """cpu"""
				__SCREAMING_SNAKE_CASE				=					True
				__SCREAMING_SNAKE_CASE				=					[
				    """decoder_num_inference_steps""",
				    """super_res_num_inference_steps""",
				]

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




		def       snake_case_	(	self):
				__SCREAMING_SNAKE_CASE				=					[
				    """decoder_num_inference_steps""",
				    """super_res_num_inference_steps""",
				]

				if torch_device == "mps":
						# TODO: MPS errors with larger batch sizes
						__SCREAMING_SNAKE_CASE				=					[2, 3]
						self._test_inference_batch_consistent(
						    batch_sizes=UpperCamelCase_				,    additional_params_copy_to_batched_inputs=UpperCamelCase_				,    )
				else:
						self._test_inference_batch_consistent(
						    additional_params_copy_to_batched_inputs=UpperCamelCase_)




		@skip_mps
		def       snake_case_	(	self):
				return super().test_dict_tuple_outputs_equivalent()




		@skip_mps
		def       snake_case_	(	self):
				return super().test_save_load_local()




		@skip_mps
		def       snake_case_	(	self):
				return super().test_save_load_optional_components()



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




		"""simple docstring"""





		def       snake_case_	(	self):
				super().tearDown()
				gc.collect()
				torch.cuda.empty_cache()




		def       snake_case_	(	self):
				__SCREAMING_SNAKE_CASE				=					load_image(
				    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/unclip/cat.png""")
				__SCREAMING_SNAKE_CASE				=					load_numpy(
				    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"""
				    """/unclip/karlo_v1_alpha_cat_variation_fp16.npy""")

				__SCREAMING_SNAKE_CASE				=					UnCLIPImageVariationPipeline.from_pretrained(
				    """kakaobrain/karlo-v1-alpha-image-variations"""				,    torch_dtype=torch.floataa)
				__SCREAMING_SNAKE_CASE				=					pipeline.to(UpperCamelCase_)
				pipeline.set_progress_bar_config(disable=UpperCamelCase_)

				__SCREAMING_SNAKE_CASE				=					torch.Generator(device="""cpu""").manual_seed(0)
				__SCREAMING_SNAKE_CASE				=					pipeline(
				    UpperCamelCase_				,    generator=UpperCamelCase_				,    output_type="""np"""				,    )

				__SCREAMING_SNAKE_CASE				=					output.images[0]

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

				assert_mean_pixel_difference(UpperCamelCase_				,    UpperCamelCase_				,    1_5)












"""simple docstring"""
from typing import List, Optional, Union

import numpy as np

from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


snake_case : Dict     		=		logging.get_logger(__name__)



class        UpperCamelCase__ (				a_):







    """simple docstring"""
    __UpperCAmelCase           = ["""input_values""", """padding_mask"""]







    def __init__(		self :	Optional[int]				,    UpperCamelCase_ :	int = 1				,    UpperCamelCase_ :	int = 2_4_0_0_0				,    UpperCamelCase_ :	float = 0.0				,    UpperCamelCase_ :	float = None				,    UpperCamelCase_ :	float = None				,    **UpperCamelCase_ :	str				,    ):





           '''simple docstring'''

           super().__init__(feature_size=UpperCamelCase_				,    sampling_rate=UpperCamelCase_				,    padding_value=UpperCamelCase_				,    **UpperCamelCase_ )
           __magic_name__      				=    chunk_length_s
           __magic_name__      				=    overlap







    @property
    def 				a__			(		self :	List[str] ):





           '''simple docstring'''

           if self.chunk_length_s is None:
                  return None
           else:
                  return int(self.chunk_length_s * self.sampling_rate )







    @property
    def 				a__			(		self :	Optional[Any] ):





           '''simple docstring'''

           if self.chunk_length_s is None or self.overlap is None:
                  return None
           else:
                  return max(1				,    int((1.0 - self.overlap) * self.chunk_length ) )







    def __call__(		self :	List[Any]				,    UpperCamelCase_ :	Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]]				,    UpperCamelCase_ :	Optional[Union[bool, str, PaddingStrategy]] = None				,    UpperCamelCase_ :	Optional[bool] = False				,    UpperCamelCase_ :	Optional[int] = None				,    UpperCamelCase_ :	Optional[Union[str, TensorType]] = None				,    UpperCamelCase_ :	Optional[int] = None				,    ):





           '''simple docstring'''

           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 padding and truncation:
                  raise ValueError('Both padding and truncation were set. Make sure you only set one.' )
           elif padding is None:
                  # by default let's pad the inputs
                  __magic_name__      				=    True

           __magic_name__      				=    bool(
               isinstance(UpperCamelCase_				,    (list, tuple) ) and (isinstance(raw_audio[0]				,    (np.ndarray, tuple, list) )) )

           if is_batched:
                  __magic_name__      				=    [np.asarray(UpperCamelCase_				,    dtype=np.floataa ).T for audio in raw_audio]
           elif not is_batched and not isinstance(UpperCamelCase_				,    np.ndarray ):
                  __magic_name__      				=    np.asarray(UpperCamelCase_				,    dtype=np.floataa )
           elif isinstance(UpperCamelCase_				,    np.ndarray ) and raw_audio.dtype is np.dtype(np.floataa ):
                  __magic_name__      				=    raw_audio.astype(np.floataa )

           # always return batch
           if not is_batched:
                  __magic_name__      				=    [np.asarray(UpperCamelCase_ ).T]

           # verify inputs are valid
           for idx, example in enumerate(UpperCamelCase_ ):
                  if example.ndim > 2:
                         raise ValueError(f"""Expected input shape (channels, length) but got shape {example.shape}""" )
                  if self.feature_size == 1 and example.ndim != 1:
                         raise ValueError(f"""Expected mono audio but example has {example.shape[-1]} channels""" )
                  if self.feature_size == 2 and example.shape[-1] != 2:
                         raise ValueError(f"""Expected stereo audio but example has {example.shape[-1]} channels""" )

           __magic_name__      				=    None
           __magic_name__      				=    BatchFeature({'input_values': raw_audio} )
           if self.chunk_stride is not None and self.chunk_length is not None and max_length is None:
                  if truncation:
                         __magic_name__      				=    min(array.shape[0] for array in raw_audio )
                         __magic_name__      				=    int(np.floor(max_length / self.chunk_stride ) )
                         __magic_name__      				=    (nb_step - 1) * self.chunk_stride + self.chunk_length
                  elif padding:
                         __magic_name__      				=    max(array.shape[0] for array in raw_audio )
                         __magic_name__      				=    int(np.ceil(max_length / self.chunk_stride ) )
                         __magic_name__      				=    (nb_step - 1) * self.chunk_stride + self.chunk_length
                         __magic_name__      				=    'max_length'
                  else:
                         __magic_name__      				=    input_values

        # normal padding on batch
           if padded_inputs is None:
                  __magic_name__      				=    self.pad(
                      UpperCamelCase_				,    max_length=UpperCamelCase_				,    truncation=UpperCamelCase_				,    padding=UpperCamelCase_				,    return_attention_mask=UpperCamelCase_				,    )
                  if padding:
                         __magic_name__      				=    padded_inputs.pop('attention_mask' )

           __magic_name__      				=    []
           for example in padded_inputs.pop('input_values' ):
                  if self.feature_size == 1:
                         __magic_name__      				=    example[..., None]
                  input_values.append(example.T )

           __magic_name__      				=    input_values
           if return_tensors is not None:
                  __magic_name__      				=    padded_inputs.convert_to_tensors(UpperCamelCase_ )

           return padded_inputs