






import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import MaskaFormerConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch

 from transformers import MaskaFormerForUniversalSegmentation, MaskaFormerModel

 if is_vision_available():
  from transformers import MaskaFormerImageProcessor

if is_vision_available():
 from PIL import Image



class       a					:

     '''simple docstring'''





     def __init__(     self       :      int ,   __snake_case       :      Any ,   __snake_case       :      Dict=2 ,   __snake_case       :      List[Any]=True ,   __snake_case       :      Union[str, Any]=False ,   __snake_case       :      Union[str, Any]=10 ,   __snake_case       :      List[str]=3 ,   __snake_case       :      Optional[Any]=32 * 8 ,   __snake_case       :      Tuple=32 * 8 ,   __snake_case       :      List[str]=4 ,   __snake_case       :      int=64 ,   ):
         UpperCAmelCase_										=					parent
         UpperCAmelCase_										=					batch_size
         UpperCAmelCase_										=					is_training
         UpperCAmelCase_										=					use_auxiliary_loss
         UpperCAmelCase_										=					num_queries
         UpperCAmelCase_										=					num_channels
         UpperCAmelCase_										=					min_size
         UpperCAmelCase_										=					max_size
         UpperCAmelCase_										=					num_labels
         UpperCAmelCase_										=					hidden_dim
         UpperCAmelCase_										=					hidden_dim
     def   lowerCamelCase_       (     self       :      int    ):
         UpperCAmelCase_										=					floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]    ).to(
             __snake_case    )

         UpperCAmelCase_										=					torch.ones([self.batch_size, self.min_size, self.max_size] ,   device=__snake_case    )

         UpperCAmelCase_										=					(
             torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size] ,   device=__snake_case    ) > 0.5
         ).float()
         UpperCAmelCase_										=					(torch.rand((self.batch_size, self.num_labels) ,   device=__snake_case    ) > 0.5).long()

         UpperCAmelCase_										=					self.get_config()
         return config, pixel_values, pixel_mask, mask_labels, class_labels
     def   lowerCamelCase_       (     self       :      List[str]    ):
         UpperCAmelCase_										=					MaskaFormerConfig(
             hidden_size=self.hidden_dim ,   )
         UpperCAmelCase_										=					self.num_queries
         UpperCAmelCase_										=					self.num_labels

         UpperCAmelCase_										=					[1, 1, 1, 1]
         UpperCAmelCase_										=					self.num_channels

         UpperCAmelCase_										=					64
         UpperCAmelCase_										=					1_28
         UpperCAmelCase_										=					self.hidden_dim
         UpperCAmelCase_										=					self.hidden_dim
         UpperCAmelCase_										=					self.hidden_dim
         return config
     def   lowerCamelCase_       (     self       :      Tuple    ):
         UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_										=					self.prepare_config_and_inputs()
         UpperCAmelCase_										=					{'''pixel_values''': pixel_values, '''pixel_mask''': pixel_mask}
         return config, inputs_dict
     def   lowerCamelCase_       (     self       :      str ,   __snake_case       :      str ,   __snake_case       :      Optional[Any]    ):
         UpperCAmelCase_										=					output.encoder_hidden_states
         UpperCAmelCase_										=					output.pixel_decoder_hidden_states
         UpperCAmelCase_										=					output.transformer_decoder_hidden_states

         self.parent.assertTrue(len(__snake_case    ) ,   len(config.backbone_config.depths    )    )
         self.parent.assertTrue(len(__snake_case    ) ,   len(config.backbone_config.depths    )    )
         self.parent.assertTrue(len(__snake_case    ) ,   config.decoder_layers    )
     def   lowerCamelCase_       (     self       :      Any ,   __snake_case       :      Union[str, Any] ,   __snake_case       :      List[Any] ,   __snake_case       :      Optional[Any] ,   __snake_case       :      Optional[int]=False    ):
         with torch.no_grad():
             UpperCAmelCase_										=					MaskaFormerModel(config=__snake_case    )
             model.to(__snake_case    )
             model.eval()

             UpperCAmelCase_										=					model(pixel_values=__snake_case ,   pixel_mask=__snake_case    )
             UpperCAmelCase_										=					model(__snake_case ,   output_hidden_states=__snake_case    )

         self.parent.assertEqual(
             output.transformer_decoder_last_hidden_state.shape ,   (self.batch_size, self.num_queries, self.hidden_dim) ,   )
         # let's ensure the other two hidden state exists
         self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None    )
         self.parent.assertTrue(output.encoder_last_hidden_state is not None    )

         if output_hidden_states:
             self.check_output_hidden_state(__snake_case ,   __snake_case    )




     def   lowerCamelCase_       (     self       :      Union[str, Any] ,   __snake_case       :      Union[str, Any] ,   __snake_case       :      Optional[Any] ,   __snake_case       :      Any ,   __snake_case       :      Tuple ,   __snake_case       :      Optional[Any]    ):
         UpperCAmelCase_										=					MaskaFormerForUniversalSegmentation(config=__snake_case    )
         model.to(__snake_case    )
         model.eval()

         def comm_check_on_output(__snake_case       :      Tuple    ):
             # let's still check that all the required stuff is there
             self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None    )
             self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None    )
             self.parent.assertTrue(result.encoder_last_hidden_state is not None    )
             # okay, now we need to check the logits shape
             # due to the encoder compression, masks have a //4 spatial size
             self.parent.assertEqual(
                 result.masks_queries_logits.shape ,   (self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4) ,   )
             # + 1 for null class
             self.parent.assertEqual(
                 result.class_queries_logits.shape ,   (self.batch_size, self.num_queries, self.num_labels + 1)    )

         with torch.no_grad():
             UpperCAmelCase_										=					model(pixel_values=__snake_case ,   pixel_mask=__snake_case    )
             UpperCAmelCase_										=					model(__snake_case    )

             comm_check_on_output(__snake_case    )

             UpperCAmelCase_										=					model(
                 pixel_values=__snake_case ,   pixel_mask=__snake_case ,   mask_labels=__snake_case ,   class_labels=__snake_case    )

         comm_check_on_output(__snake_case    )

         self.parent.assertTrue(result.loss is not None    )
         self.parent.assertEqual(result.loss.shape ,   torch.Size([1]    )    )



@require_torch
class       a					(       _A     ,       _A     ,       unittest.TestCase      ):

     '''simple docstring'''





     lowerCAmelCase    :	Optional[Any]       		=  (MaskaFormerModel, MaskaFormerForUniversalSegmentation) if is_torch_available() else ()
     lowerCAmelCase    :	Union[str, Any]       		=  {'feature-extraction': MaskaFormerModel} if is_torch_available() else {}

     lowerCAmelCase    :	List[str]       		=  False
     lowerCAmelCase    :	Union[str, Any]       		=  False
     lowerCAmelCase    :	Optional[Any]       		=  False
     lowerCAmelCase    :	Tuple       		=  False
     def   lowerCamelCase_       (     self       :      Union[str, Any]    ):
         UpperCAmelCase_										=					MaskaFormerModelTester(self    )
         UpperCAmelCase_										=					ConfigTester(self ,   config_class=__snake_case ,   has_text_modality=__snake_case    )
     def   lowerCamelCase_       (     self       :      List[Any]    ):
         self.config_tester.run_common_tests()
     def   lowerCamelCase_       (     self       :      Tuple    ):
         UpperCAmelCase_			,							UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs_for_common()
         self.model_tester.create_and_check_maskaformer_model(__snake_case ,   **__snake_case ,   output_hidden_states=__snake_case    )
     def   lowerCamelCase_       (     self       :      Tuple    ):
         UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_maskaformer_instance_segmentation_head_model(*__snake_case    )
     @unittest.skip(reason='''Mask2Former does not use inputs_embeds'''    )
     def   lowerCamelCase_       (     self       :      Optional[int]    ):
         pass
     @unittest.skip(reason='''Mask2Former does not have a get_input_embeddings method'''    )
     def   lowerCamelCase_       (     self       :      Tuple    ):
         pass
     @unittest.skip(reason='''Mask2Former is not a generative model'''    )
     def   lowerCamelCase_       (     self       :      List[Any]    ):
         pass
     @unittest.skip(reason='''Mask2Former does not use token embeddings'''    )
     def   lowerCamelCase_       (     self       :      Dict    ):
         pass
     @require_torch_multi_gpu
     @unittest.skip(
         reason='''Mask2Former has some layers using `add_module` which doesn\'t work well with `nn.DataParallel`'''    )
     def   lowerCamelCase_       (     self       :      Any    ):
         pass
     @unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''    )
     def   lowerCamelCase_       (     self       :      str    ):
         pass
     def   lowerCamelCase_       (     self       :      Optional[int]    ):
         UpperCAmelCase_			,							UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
             UpperCAmelCase_										=					model_class(__snake_case    )
             UpperCAmelCase_										=					inspect.signature(model.forward    )
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             UpperCAmelCase_										=					[*signature.parameters.keys()]

             UpperCAmelCase_										=					['''pixel_values''']
             self.assertListEqual(arg_names[:1] ,   __snake_case    )
     @slow
     def   lowerCamelCase_       (     self       :      Optional[Any]    ):
         for model_name in ["facebook/mask2former-swin-small-coco-instance"]:
             UpperCAmelCase_										=					MaskaFormerModel.from_pretrained(__snake_case    )
             self.assertIsNotNone(__snake_case    )
     def   lowerCamelCase_       (     self       :      int    ):
         UpperCAmelCase_										=					(self.model_tester.min_size,) * 2
         UpperCAmelCase_										=					{
             '''pixel_values''': torch.randn((2, 3, *size) ,   device=__snake_case    ),
             '''mask_labels''': torch.randn((2, 10, *size) ,   device=__snake_case    ),
             '''class_labels''': torch.zeros(2 ,   10 ,   device=__snake_case    ).long(),
         }
         UpperCAmelCase_										=					self.model_tester.get_config()

         UpperCAmelCase_										=					MaskaFormerForUniversalSegmentation(__snake_case    ).to(__snake_case    )
         UpperCAmelCase_										=					model(**__snake_case    )
         self.assertTrue(outputs.loss is not None    )
     def   lowerCamelCase_       (     self       :      Dict    ):
         UpperCAmelCase_			,							UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs_for_common()
         self.model_tester.create_and_check_maskaformer_model(__snake_case ,   **__snake_case ,   output_hidden_states=__snake_case    )
     def   lowerCamelCase_       (     self       :      Union[str, Any]    ):
         UpperCAmelCase_			,							UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
             UpperCAmelCase_										=					model_class(__snake_case    ).to(__snake_case    )
             UpperCAmelCase_										=					model(**__snake_case ,   output_attentions=__snake_case    )
             self.assertTrue(outputs.attentions is not None    )
     def   lowerCamelCase_       (     self       :      Optional[Any]    ):
         if not self.model_tester.is_training:
             return

         UpperCAmelCase_										=					self.all_model_classes[1]
         UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs()

         UpperCAmelCase_										=					model_class(__snake_case    )
         model.to(__snake_case    )
         model.train()

         UpperCAmelCase_										=					model(__snake_case ,   mask_labels=__snake_case ,   class_labels=__snake_case    ).loss
         loss.backward()




     def   lowerCamelCase_       (     self       :      Any    ):
         UpperCAmelCase_										=					self.all_model_classes[1]
         UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_			,							UpperCAmelCase_										=					self.model_tester.prepare_config_and_inputs()
         UpperCAmelCase_										=					True
         UpperCAmelCase_										=					True

         UpperCAmelCase_										=					model_class(__snake_case    ).to(__snake_case    )
         model.train()

         UpperCAmelCase_										=					model(__snake_case ,   mask_labels=__snake_case ,   class_labels=__snake_case    )

         UpperCAmelCase_										=					outputs.encoder_hidden_states[0]
         encoder_hidden_states.retain_grad()

         UpperCAmelCase_										=					outputs.pixel_decoder_hidden_states[0]
         pixel_decoder_hidden_states.retain_grad()

         UpperCAmelCase_										=					outputs.transformer_decoder_hidden_states[0]
         transformer_decoder_hidden_states.retain_grad()

         UpperCAmelCase_										=					outputs.attentions[0]
         attentions.retain_grad()

         outputs.loss.backward(retain_graph=__snake_case    )

         self.assertIsNotNone(encoder_hidden_states.grad    )
         self.assertIsNotNone(pixel_decoder_hidden_states.grad    )
         self.assertIsNotNone(transformer_decoder_hidden_states.grad    )
         self.assertIsNotNone(attentions.grad    )


_lowerCamelCase      			=						1e-4




def  SCREAMING_SNAKE_CASE     (	)  ->							Dict:
    UpperCAmelCase_										=					Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''				)
    return image



@require_vision
@slow
class       a					(       unittest.TestCase      ):

     '''simple docstring'''





     @cached_property
     def   lowerCamelCase_       (     self       :      int    ):
         return "facebook/mask2former-swin-small-coco-instance"
     @cached_property
     def   lowerCamelCase_       (     self       :      Optional[Any]    ):
         return MaskaFormerImageProcessor.from_pretrained(self.model_checkpoints    ) if is_vision_available() else None
     def   lowerCamelCase_       (     self       :      int    ):
         UpperCAmelCase_										=					MaskaFormerModel.from_pretrained(self.model_checkpoints    ).to(__snake_case    )
         UpperCAmelCase_										=					self.default_image_processor
         UpperCAmelCase_										=					prepare_img()
         UpperCAmelCase_										=					image_processor(__snake_case ,   return_tensors='''pt'''    ).to(__snake_case    )
         UpperCAmelCase_										=					inputs['''pixel_values'''].shape
         # check size is divisible by 32
         self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0    )
         # check size
         self.assertEqual(__snake_case ,   (1, 3, 3_84, 3_84)    )

         with torch.no_grad():
             UpperCAmelCase_										=					model(**__snake_case    )

         UpperCAmelCase_										=					torch.tensor(
             [[-0.2_790, -1.0_717, -1.1_668], [-0.5_128, -0.3_128, -0.4_987], [-0.5_832, 0.1_971, -0.0_197]]    ).to(__snake_case    )
         self.assertTrue(
             torch.allclose(
                 outputs.encoder_last_hidden_state[0, 0, :3, :3] ,   __snake_case ,   atol=__snake_case    )    )

         UpperCAmelCase_										=					torch.tensor(
             [[0.8_973, 1.1_847, 1.1_776], [1.1_934, 1.5_040, 1.5_128], [1.1_153, 1.4_486, 1.4_951]]    ).to(__snake_case    )
         self.assertTrue(
             torch.allclose(
                 outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3] ,   __snake_case ,   atol=__snake_case    )    )

         UpperCAmelCase_										=					torch.tensor(
             [[2.1_152, 1.7_000, -0.8_603], [1.5_808, 1.8_004, -0.9_353], [1.6_043, 1.7_495, -0.5_999]]    ).to(__snake_case    )
         self.assertTrue(
             torch.allclose(
                 outputs.transformer_decoder_last_hidden_state[0, :3, :3] ,   __snake_case ,   atol=__snake_case    )    )
     def   lowerCamelCase_       (     self       :      List[Any]    ):
         UpperCAmelCase_										=					MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints    ).to(__snake_case    ).eval()
         UpperCAmelCase_										=					self.default_image_processor
         UpperCAmelCase_										=					prepare_img()
         UpperCAmelCase_										=					image_processor(__snake_case ,   return_tensors='''pt'''    ).to(__snake_case    )
         UpperCAmelCase_										=					inputs['''pixel_values'''].shape
         # check size is divisible by 32
         self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0    )
         # check size
         self.assertEqual(__snake_case ,   (1, 3, 3_84, 3_84)    )

         with torch.no_grad():
             UpperCAmelCase_										=					model(**__snake_case    )
         # masks_queries_logits
         UpperCAmelCase_										=					outputs.masks_queries_logits
         self.assertEqual(
             masks_queries_logits.shape ,   (1, model.config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)    )
         UpperCAmelCase_										=					[
             [-8.7_839, -9.0_056, -8.8_121],
             [-7.4_104, -7.0_313, -6.5_401],
             [-6.6_105, -6.3_427, -6.4_675],
         ]
         UpperCAmelCase_										=					torch.tensor(__snake_case    ).to(__snake_case    )
         self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3] ,   __snake_case ,   atol=__snake_case    )    )
         # class_queries_logits
         UpperCAmelCase_										=					outputs.class_queries_logits
         self.assertEqual(class_queries_logits.shape ,   (1, model.config.num_queries, model.config.num_labels + 1)    )
         UpperCAmelCase_										=					torch.tensor(
             [
                 [1.8_324, -8.0_835, -4.1_922],
                 [0.8_450, -9.0_050, -3.6_053],
                 [0.3_045, -7.7_293, -3.0_275],
             ]    ).to(__snake_case    )
         self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3] ,   __snake_case ,   atol=__snake_case    )    )




     def   lowerCamelCase_       (     self       :      Optional[Any]    ):
         UpperCAmelCase_										=					MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints    ).to(__snake_case    ).eval()
         UpperCAmelCase_										=					self.default_image_processor

         UpperCAmelCase_										=					image_processor(
             [np.zeros((3, 8_00, 13_33)    ), np.zeros((3, 8_00, 13_33)    )] ,   segmentation_maps=[np.zeros((3_84, 3_84)    ).astype(np.floataa    ), np.zeros((3_84, 3_84)    ).astype(np.floataa    )] ,   return_tensors='''pt''' ,   )

         UpperCAmelCase_										=					inputs['''pixel_values'''].to(__snake_case    )
         UpperCAmelCase_										=					[el.to(__snake_case    ) for el in inputs['''mask_labels''']]
         UpperCAmelCase_										=					[el.to(__snake_case    ) for el in inputs['''class_labels''']]

         with torch.no_grad():
             UpperCAmelCase_										=					model(**__snake_case    )

         self.assertTrue(outputs.loss is not None    )











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


_lowerCamelCase      			=						logging.get_logger(__name__)



class       a					(       _A      ):

     '''simple docstring'''





     lowerCAmelCase    :	str       		=  ['input_values', 'padding_mask']
     def __init__(     self       :      Optional[Any] ,   __snake_case       :      int = 1 ,   __snake_case       :      int = 2_40_00 ,   __snake_case       :      float = 0.0 ,   __snake_case       :      float = None ,   __snake_case       :      float = None ,   **__snake_case       :      Dict ,   ):
         super().__init__(feature_size=__snake_case ,   sampling_rate=__snake_case ,   padding_value=__snake_case ,   **__snake_case    )
         UpperCAmelCase_										=					chunk_length_s
         UpperCAmelCase_										=					overlap
     @property
     def   lowerCamelCase_       (     self       :      List[str]    ):
         if self.chunk_length_s is None:
             return None
         else:
             return int(self.chunk_length_s * self.sampling_rate    )
     @property
     def   lowerCamelCase_       (     self       :      List[str]    ):
         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[str] ,   __snake_case       :      Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]] ,   __snake_case       :      Optional[Union[bool, str, PaddingStrategy]] = None ,   __snake_case       :      Optional[bool] = False ,   __snake_case       :      Optional[int] = None ,   __snake_case       :      Optional[Union[str, TensorType]] = None ,   __snake_case       :      Optional[int] = None ,   ):
         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
             UpperCAmelCase_										=					True

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

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

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

         # verify inputs are valid
         for idx, example in enumerate(__snake_case    ):
             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'    )

         UpperCAmelCase_										=					None
         UpperCAmelCase_										=					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:
                 UpperCAmelCase_										=					min(array.shape[0] for array in raw_audio    )
                 UpperCAmelCase_										=					int(np.floor(max_length / self.chunk_stride    )    )
                 UpperCAmelCase_										=					(nb_step - 1) * self.chunk_stride + self.chunk_length
             elif padding:
                 UpperCAmelCase_										=					max(array.shape[0] for array in raw_audio    )
                 UpperCAmelCase_										=					int(np.ceil(max_length / self.chunk_stride    )    )
                 UpperCAmelCase_										=					(nb_step - 1) * self.chunk_stride + self.chunk_length
                 UpperCAmelCase_										=					'''max_length'''
             else:
                 UpperCAmelCase_										=					input_values

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

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

         UpperCAmelCase_										=					input_values
         if return_tensors is not None:
             UpperCAmelCase_										=					padded_inputs.convert_to_tensors(__snake_case    )

         return padded_inputs





