

'''simple docstring'''





import argparse
import json
import os
import sys
import tempfile
import unittest
from argparse import Namespace
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional

import yaml

from transformers import HfArgumentParser, TrainingArguments
from transformers.hf_argparser import make_choice_type_function, string_to_bool


# Since Python 3.10, we can use the builtin `|` operator for Union types
# See PEP 604: https://peps.python.org/pep-0604
UpperCAmelCase__ :     Dict				    =    sys.version_info >= (3, 10)






def 					__lowercase      (     _A=None						,    _A=None			)     ->						Union[str, Any]:
      return field(default_factory=lambda: default						,    metadata=_lowerCAmelCase			)







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : Union[str, Any]			       =4_2
  UpperCAmelCase__      : Optional[Any]			       =4_2
  UpperCAmelCase__      : Optional[int]			       =4_2
  UpperCAmelCase__      : Tuple			       =4_2







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : List[Any]			       =4_2
  UpperCAmelCase__      : List[str]			       =field(default="""toto"""	,			metadata={"""help""": """help message"""}       )







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : List[Any]			       =False
  UpperCAmelCase__      : Optional[int]			       =True
  UpperCAmelCase__      : str			       =None







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Dict			       ="""titi"""
  UpperCAmelCase__      : Dict			       ="""toto"""







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Tuple			       ="""titi"""
  UpperCAmelCase__      : Optional[Any]			       ="""toto"""
  UpperCAmelCase__      : Tuple			       =4_2







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : Tuple			       ="""toto"""


  def  _lowercase      (			self    : Optional[Any]		)					->Optional[int]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[Any]       =   BasicEnum(self.foo		)







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : Any			       ="""toto"""


  def  _lowercase      (			self    : str		)					->List[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Tuple       =   MixedTypeEnum(self.foo		)







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : Dict			       =None
  UpperCAmelCase__      : Dict			       =field(default=UpperCAmelCase	,			metadata={"""help""": """help message"""}       )
  UpperCAmelCase__      : Tuple			       =None
  UpperCAmelCase__      : Union[str, Any]			       =list_field(default=[]       )
  UpperCAmelCase__      : Union[str, Any]			       =list_field(default=[]       )







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : Tuple			       =list_field(default=[]       )
  UpperCAmelCase__      : Any			       =list_field(default=[1, 2, 3]       )
  UpperCAmelCase__      : Optional[int]			       =list_field(default=["""Hallo""", """Bonjour""", """Hello"""]       )
  UpperCAmelCase__      : Dict			       =list_field(default=[0.1, 0.2, 0.3]       )







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : Optional[Any]			       =field()
  UpperCAmelCase__      : List[str]			       =field()
  UpperCAmelCase__      : Dict			       =field()


  def  _lowercase      (			self    : Tuple		)					->Optional[int]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   BasicEnum(self.required_enum		)







@dataclass
class        a__       :







  """simple docstring"""




  UpperCAmelCase__      : int			       =4_2
  UpperCAmelCase__      : Tuple			       =field()
  UpperCAmelCase__      : Optional[Any]			       =None
  UpperCAmelCase__      : Union[str, Any]			       =field(default="""toto"""	,			metadata={"""help""": """help message"""}       )
  UpperCAmelCase__      : Union[str, Any]			       =list_field(default=["""Hallo""", """Bonjour""", """Hello"""]       )


if is_python_no_less_than_3_10:







  @dataclass
  class        a__       :







    """simple docstring"""




    UpperCAmelCase__      : Dict			       =False
    UpperCAmelCase__      : int			       =True
    UpperCAmelCase__      : Dict			       =None







  @dataclass
  class        a__       :







    """simple docstring"""




    UpperCAmelCase__      : Union[str, Any]			       =None
    UpperCAmelCase__      : Tuple			       =field(default=UpperCAmelCase	,			metadata={"""help""": """help message"""}       )
    UpperCAmelCase__      : Any			       =None
    UpperCAmelCase__      : Optional[Any]			       =list_field(default=[]       )
    UpperCAmelCase__      : Any			       =list_field(default=[]       )







class        a__       (   unittest.TestCase       ):







  """simple docstring"""




  def  _lowercase      (			self    : int				,				UpperCAmelCase__    : argparse.ArgumentParser				,				UpperCAmelCase__    : argparse.ArgumentParser		)					->Union[str, Any]:
        """simple docstring"""







        self.assertEqual(len(a._actions		)				,				len(b._actions		)		)
        for x, y in zip(a._actions				,				b._actions		):
              SCREAMING_SNAKE_CASE :      List[str]       =   {k: v for k, v in vars(__A		).items() if k != "container"}
              SCREAMING_SNAKE_CASE :      List[Any]       =   {k: v for k, v in vars(__A		).items() if k != "container"}

              # Choices with mixed type have custom function as "type"
              # So we need to compare results directly for equality
              if xx.get("""choices"""				,				__A		) and yy.get("""choices"""				,				__A		):
                    for expected_choice in yy["choices"] + xx["choices"]:
                          self.assertEqual(xx["""type"""](__A		)				,				yy["""type"""](__A		)		)
                    del xx["type"], yy["type"]

              self.assertEqual(__A				,				__A		)


  def  _lowercase      (			self    : Union[str, Any]		)					->Union[str, Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   argparse.ArgumentParser()
        expected.add_argument("""--foo"""				,				type=__A				,				required=__A		)
        expected.add_argument("""--bar"""				,				type=__A				,				required=__A		)
        expected.add_argument("""--baz"""				,				type=__A				,				required=__A		)
        expected.add_argument("""--flag"""				,				type=__A				,				default=__A				,				const=__A				,				nargs="""?"""		)
        self.argparsersEqual(__A				,				__A		)

        SCREAMING_SNAKE_CASE :      Any       =   ["--foo", "1", "--baz", "quux", "--bar", "0.5"]
        (SCREAMING_SNAKE_CASE		) :      Tuple       =   parser.parse_args_into_dataclasses(__A				,				look_for_args_file=__A		)
        self.assertFalse(example.flag		)


  def  _lowercase      (			self    : Union[str, Any]		)					->Union[str, Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      Optional[int]       =   argparse.ArgumentParser()
        expected.add_argument("""--foo"""				,				default=4_2				,				type=__A		)
        expected.add_argument("""--baz"""				,				default="""toto"""				,				type=__A				,				help="""help message"""		)
        self.argparsersEqual(__A				,				__A		)


  def  _lowercase      (			self    : Tuple		)					->Dict:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[Any]       =   argparse.ArgumentParser()
        expected.add_argument("""--foo"""				,				type=__A				,				default=__A				,				const=__A				,				nargs="""?"""		)
        expected.add_argument("""--baz"""				,				type=__A				,				default=__A				,				const=__A				,				nargs="""?"""		)
        # A boolean no_* argument always has to come after its "default: True" regular counter-part
        # and its default must be set to False
        expected.add_argument("""--no_baz"""				,				action="""store_false"""				,				default=__A				,				dest="""baz"""		)
        expected.add_argument("""--opt"""				,				type=__A				,				default=__A		)

        SCREAMING_SNAKE_CASE :      Tuple       =   [WithDefaultBoolExample]
        if is_python_no_less_than_3_10:
              dataclass_types.append(__A		)

        for dataclass_type in dataclass_types:
              SCREAMING_SNAKE_CASE :      str       =   HfArgumentParser(__A		)
              self.argparsersEqual(__A				,				__A		)

              SCREAMING_SNAKE_CASE :      Optional[Any]       =   parser.parse_args([]		)
              self.assertEqual(__A				,				Namespace(foo=__A				,				baz=__A				,				opt=__A		)		)

              SCREAMING_SNAKE_CASE :      Dict       =   parser.parse_args(["""--foo""", """--no_baz"""]		)
              self.assertEqual(__A				,				Namespace(foo=__A				,				baz=__A				,				opt=__A		)		)

              SCREAMING_SNAKE_CASE :      Optional[Any]       =   parser.parse_args(["""--foo""", """--baz"""]		)
              self.assertEqual(__A				,				Namespace(foo=__A				,				baz=__A				,				opt=__A		)		)

              SCREAMING_SNAKE_CASE :      Optional[int]       =   parser.parse_args(["""--foo""", """True""", """--baz""", """True""", """--opt""", """True"""]		)
              self.assertEqual(__A				,				Namespace(foo=__A				,				baz=__A				,				opt=__A		)		)

              SCREAMING_SNAKE_CASE :      List[str]       =   parser.parse_args(["""--foo""", """False""", """--baz""", """False""", """--opt""", """False"""]		)
              self.assertEqual(__A				,				Namespace(foo=__A				,				baz=__A				,				opt=__A		)		)


  def  _lowercase      (			self    : Union[str, Any]		)					->List[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[str]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   argparse.ArgumentParser()
        expected.add_argument(
            """--foo"""				,				default="""toto"""				,				choices=["""titi""", """toto""", 4_2]				,				type=make_choice_type_function(["""titi""", """toto""", 4_2]		)				,				)
        self.argparsersEqual(__A				,				__A		)

        SCREAMING_SNAKE_CASE :      Optional[Any]       =   parser.parse_args([]		)
        self.assertEqual(args.foo				,				"""toto"""		)
        SCREAMING_SNAKE_CASE :      str       =   parser.parse_args_into_dataclasses([]		)[0]
        self.assertEqual(enum_ex.foo				,				MixedTypeEnum.toto		)

        SCREAMING_SNAKE_CASE :      int       =   parser.parse_args(["""--foo""", """titi"""]		)
        self.assertEqual(args.foo				,				"""titi"""		)
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   parser.parse_args_into_dataclasses(["""--foo""", """titi"""]		)[0]
        self.assertEqual(enum_ex.foo				,				MixedTypeEnum.titi		)

        SCREAMING_SNAKE_CASE :      Optional[int]       =   parser.parse_args(["""--foo""", """42"""]		)
        self.assertEqual(args.foo				,				4_2		)
        SCREAMING_SNAKE_CASE :      Any       =   parser.parse_args_into_dataclasses(["""--foo""", """42"""]		)[0]
        self.assertEqual(enum_ex.foo				,				MixedTypeEnum.fourtytwo		)


  def  _lowercase      (			self    : Union[str, Any]		)					->Optional[int]:
        """simple docstring"""







        @dataclass
        class        a__       :







          """simple docstring"""




          UpperCAmelCase__      : Tuple			       ="""toto"""


        SCREAMING_SNAKE_CASE :      int       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      str       =   argparse.ArgumentParser()
        expected.add_argument(
            """--foo"""				,				default="""toto"""				,				choices=("""titi""", """toto""", 4_2)				,				type=make_choice_type_function(["""titi""", """toto""", 4_2]		)				,				)
        self.argparsersEqual(__A				,				__A		)

        SCREAMING_SNAKE_CASE :      Any       =   parser.parse_args([]		)
        self.assertEqual(args.foo				,				"""toto"""		)

        SCREAMING_SNAKE_CASE :      Optional[Any]       =   parser.parse_args(["""--foo""", """titi"""]		)
        self.assertEqual(args.foo				,				"""titi"""		)

        SCREAMING_SNAKE_CASE :      int       =   parser.parse_args(["""--foo""", """42"""]		)
        self.assertEqual(args.foo				,				4_2		)


  def  _lowercase      (			self    : int		)					->Union[str, Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      Any       =   argparse.ArgumentParser()
        expected.add_argument("""--foo_int"""				,				nargs="""+"""				,				default=[]				,				type=__A		)
        expected.add_argument("""--bar_int"""				,				nargs="""+"""				,				default=[1, 2, 3]				,				type=__A		)
        expected.add_argument("""--foo_str"""				,				nargs="""+"""				,				default=["""Hallo""", """Bonjour""", """Hello"""]				,				type=__A		)
        expected.add_argument("""--foo_float"""				,				nargs="""+"""				,				default=[0.1, 0.2, 0.3]				,				type=__A		)

        self.argparsersEqual(__A				,				__A		)

        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   parser.parse_args([]		)
        self.assertEqual(
            __A				,				Namespace(foo_int=[]				,				bar_int=[1, 2, 3]				,				foo_str=["""Hallo""", """Bonjour""", """Hello"""]				,				foo_float=[0.1, 0.2, 0.3]		)				,				)

        SCREAMING_SNAKE_CASE :      Any       =   parser.parse_args("""--foo_int 1 --bar_int 2 3 --foo_str a b c --foo_float 0.1 0.7""".split()		)
        self.assertEqual(__A				,				Namespace(foo_int=[1]				,				bar_int=[2, 3]				,				foo_str=["""a""", """b""", """c"""]				,				foo_float=[0.1, 0.7]		)		)


  def  _lowercase      (			self    : Tuple		)					->str:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[Any]       =   argparse.ArgumentParser()
        expected.add_argument("""--foo"""				,				default=__A				,				type=__A		)
        expected.add_argument("""--bar"""				,				default=__A				,				type=__A				,				help="""help message"""		)
        expected.add_argument("""--baz"""				,				default=__A				,				type=__A		)
        expected.add_argument("""--ces"""				,				nargs="""+"""				,				default=[]				,				type=__A		)
        expected.add_argument("""--des"""				,				nargs="""+"""				,				default=[]				,				type=__A		)

        SCREAMING_SNAKE_CASE :      Optional[int]       =   [OptionalExample]
        if is_python_no_less_than_3_10:
              dataclass_types.append(__A		)

        for dataclass_type in dataclass_types:
              SCREAMING_SNAKE_CASE :      Any       =   HfArgumentParser(__A		)

              self.argparsersEqual(__A				,				__A		)

              SCREAMING_SNAKE_CASE :      Union[str, Any]       =   parser.parse_args([]		)
              self.assertEqual(__A				,				Namespace(foo=__A				,				bar=__A				,				baz=__A				,				ces=[]				,				des=[]		)		)

              SCREAMING_SNAKE_CASE :      Any       =   parser.parse_args("""--foo 12 --bar 3.14 --baz 42 --ces a b c --des 1 2 3""".split()		)
              self.assertEqual(__A				,				Namespace(foo=1_2				,				bar=3.14				,				baz="""42"""				,				ces=["""a""", """b""", """c"""]				,				des=[1, 2, 3]		)		)


  def  _lowercase      (			self    : str		)					->str:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[Any]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      str       =   argparse.ArgumentParser()
        expected.add_argument("""--required_list"""				,				nargs="""+"""				,				type=__A				,				required=__A		)
        expected.add_argument("""--required_str"""				,				type=__A				,				required=__A		)
        expected.add_argument(
            """--required_enum"""				,				type=make_choice_type_function(["""titi""", """toto"""]		)				,				choices=["""titi""", """toto"""]				,				required=__A				,				)
        self.argparsersEqual(__A				,				__A		)


  def  _lowercase      (			self    : Tuple		)					->str:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      int       =   argparse.ArgumentParser()
        expected.add_argument("""--foo"""				,				type=__A				,				required=__A		)
        expected.add_argument(
            """--required_enum"""				,				type=make_choice_type_function(["""titi""", """toto"""]		)				,				choices=["""titi""", """toto"""]				,				required=__A				,				)
        expected.add_argument("""--opt"""				,				type=__A				,				default=__A		)
        expected.add_argument("""--baz"""				,				default="""toto"""				,				type=__A				,				help="""help message"""		)
        expected.add_argument("""--foo_str"""				,				nargs="""+"""				,				default=["""Hallo""", """Bonjour""", """Hello"""]				,				type=__A		)
        self.argparsersEqual(__A				,				__A		)


  def  _lowercase      (			self    : List[str]		)					->Any:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Tuple       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      Optional[Any]       =   {
            "foo": 1_2,
            "bar": 3.14,
            "baz": "42",
            "flag": True,
        }

        SCREAMING_SNAKE_CASE :      Tuple       =   parser.parse_dict(__A		)[0]
        SCREAMING_SNAKE_CASE :      str       =   BasicExample(**__A		)
        self.assertEqual(__A				,				__A		)


  def  _lowercase      (			self    : List[str]		)					->Any:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Tuple       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      str       =   {
            "foo": 1_2,
            "bar": 3.14,
            "baz": "42",
            "flag": True,
            "extra": 4_2,
        }

        self.assertRaises(__A				,				parser.parse_dict				,				__A				,				allow_extra_keys=__A		)


  def  _lowercase      (			self    : Union[str, Any]		)					->List[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Optional[int]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      List[str]       =   {
            "foo": 1_2,
            "bar": 3.14,
            "baz": "42",
            "flag": True,
        }
        with tempfile.TemporaryDirectory() as tmp_dir:
              SCREAMING_SNAKE_CASE :      Dict       =   os.path.join(__A				,				"""temp_json"""		)
              os.mkdir(__A		)
              with open(temp_local_path + """.json"""				,				"""w+"""		) as f:
                    json.dump(__A				,				__A		)
              SCREAMING_SNAKE_CASE :      Tuple       =   parser.parse_yaml_file(Path(temp_local_path + """.json"""		)		)[0]

        SCREAMING_SNAKE_CASE :      List[Any]       =   BasicExample(**__A		)
        self.assertEqual(__A				,				__A		)


  def  _lowercase      (			self    : List[str]		)					->List[str]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   HfArgumentParser(__A		)

        SCREAMING_SNAKE_CASE :      List[str]       =   {
            "foo": 1_2,
            "bar": 3.14,
            "baz": "42",
            "flag": True,
        }
        with tempfile.TemporaryDirectory() as tmp_dir:
              SCREAMING_SNAKE_CASE :      Tuple       =   os.path.join(__A				,				"""temp_yaml"""		)
              os.mkdir(__A		)
              with open(temp_local_path + """.yaml"""				,				"""w+"""		) as f:
                    yaml.dump(__A				,				__A		)
              SCREAMING_SNAKE_CASE :      List[str]       =   parser.parse_yaml_file(Path(temp_local_path + """.yaml"""		)		)[0]
        SCREAMING_SNAKE_CASE :      Optional[int]       =   BasicExample(**__A		)
        self.assertEqual(__A				,				__A		)




  def  _lowercase      (			self    : List[Any]		)					->List[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[str]       =   HfArgumentParser(__A		)
        self.assertIsNotNone(__A		)







from typing import List, Optional, Union

import numpy as np
import torch
import torchaudio.compliance.kaldi as ta_kaldi

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


UpperCAmelCase__ :     Tuple				    =    logging.get_logger(__name__)







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : Optional[int]			       =["""input_features""", """attention_mask"""]


  def __init__(			self    : List[str]				,				UpperCAmelCase__    : Optional[Any]=8_0				,				UpperCAmelCase__    : List[str]=1_6_0_0_0				,				UpperCAmelCase__    : Optional[int]=8_0				,				UpperCAmelCase__    : List[str]=0.0				,				UpperCAmelCase__    : List[Any]=True				,				UpperCAmelCase__    : Tuple=True				,				UpperCAmelCase__    : Tuple=True				,				**UpperCAmelCase__    : Optional[int]				,				)					->Optional[int]:
        """simple docstring"""







        super().__init__(feature_size=UpperCAmelCase__				,				sampling_rate=UpperCAmelCase__				,				padding_value=UpperCAmelCase__				,				**UpperCAmelCase__		)
        SCREAMING_SNAKE_CASE :      Optional[int]       =   num_mel_bins
        SCREAMING_SNAKE_CASE :      Dict       =   do_ceptral_normalize
        SCREAMING_SNAKE_CASE :      Optional[int]       =   normalize_means
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   normalize_vars
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   True


  def  _lowercase      (			self    : Tuple				,				UpperCAmelCase__    : np.ndarray				,				)					->np.ndarray:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[str]       =   waveform * (2**1_5)  # Kaldi compliance: 16-bit signed integers
        SCREAMING_SNAKE_CASE :      Dict       =   torch.from_numpy(UpperCAmelCase__		).unsqueeze(0		)
        SCREAMING_SNAKE_CASE :      List[Any]       =   ta_kaldi.fbank(UpperCAmelCase__				,				num_mel_bins=self.num_mel_bins				,				sample_frequency=self.sampling_rate		)
        return features.numpy()


  @staticmethod
  def  _lowercase      (			UpperCAmelCase__    : np.ndarray				,				UpperCAmelCase__    : int				,				UpperCAmelCase__    : Optional[bool] = True				,				UpperCAmelCase__    : Optional[bool] = True				,				UpperCAmelCase__    : float = 0.0				,				)					->np.ndarray:
        """simple docstring"""







        if normalize_means:
              SCREAMING_SNAKE_CASE :      Tuple       =   x[:input_length].mean(axis=0		)
              SCREAMING_SNAKE_CASE :      List[Any]       =   np.subtract(UpperCAmelCase__				,				UpperCAmelCase__		)
        if normalize_vars:
              SCREAMING_SNAKE_CASE :      Optional[Any]       =   x[:input_length].std(axis=0		)
              SCREAMING_SNAKE_CASE :      Union[str, Any]       =   np.divide(UpperCAmelCase__				,				UpperCAmelCase__		)

        if input_length < x.shape[0]:
              SCREAMING_SNAKE_CASE :      Tuple       =   padding_value

        # make sure array is in float32
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   x.astype(np.floataa		)

        return x


  def  _lowercase      (			self    : List[str]				,				UpperCAmelCase__    : List[np.ndarray]				,				UpperCAmelCase__    : Optional[np.ndarray] = None		)					->List[np.ndarray]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      str       =   attention_mask.sum(-1		) if attention_mask is not None else [x.shape[0] for x in input_features]
        return [
            self.utterance_cmvn(UpperCAmelCase__				,				UpperCAmelCase__				,				self.normalize_means				,				self.normalize_vars				,				self.padding_value		)
            for x, n in zip(UpperCAmelCase__				,				UpperCAmelCase__		)
        ]




  def __call__(			self    : str				,				UpperCAmelCase__    : Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]]				,				UpperCAmelCase__    : Union[bool, str, PaddingStrategy] = False				,				UpperCAmelCase__    : Optional[int] = None				,				UpperCAmelCase__    : bool = False				,				UpperCAmelCase__    : Optional[int] = None				,				UpperCAmelCase__    : Optional[Union[str, TensorType]] = None				,				UpperCAmelCase__    : Optional[int] = None				,				UpperCAmelCase__    : Optional[bool] = None				,				**UpperCAmelCase__    : Optional[int]				,				)					->BatchFeature:
        """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 `raw_speech` 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."""		)

        SCREAMING_SNAKE_CASE :      Tuple       =   isinstance(UpperCAmelCase__				,				np.ndarray		) and len(raw_speech.shape		) > 1
        if is_batched_numpy and len(raw_speech.shape		) > 2:
              raise ValueError(f"Only mono-channel audio is supported for input to {self}"		)
        SCREAMING_SNAKE_CASE :      Optional[Any]       =   is_batched_numpy or (
            isinstance(UpperCAmelCase__				,				(list, tuple)		) and (isinstance(raw_speech[0]				,				(np.ndarray, tuple, list)		))
        )

        if is_batched:
              SCREAMING_SNAKE_CASE :      Dict       =   [np.asarray(UpperCAmelCase__				,				dtype=np.floataa		) for speech in raw_speech]
        elif not is_batched and not isinstance(UpperCAmelCase__				,				np.ndarray		):
              SCREAMING_SNAKE_CASE :      Any       =   np.asarray(UpperCAmelCase__				,				dtype=np.floataa		)
        elif isinstance(UpperCAmelCase__				,				np.ndarray		) and raw_speech.dtype is np.dtype(np.floataa		):
              SCREAMING_SNAKE_CASE :      Tuple       =   raw_speech.astype(np.floataa		)

        # always return batch
        if not is_batched:
              SCREAMING_SNAKE_CASE :      Optional[Any]       =   [raw_speech]

        # extract fbank features
        SCREAMING_SNAKE_CASE :      Tuple       =   [self._extract_fbank_features(UpperCAmelCase__		) for waveform in raw_speech]

        # convert into correct format for padding
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   BatchFeature({"""input_features""": features}		)

        SCREAMING_SNAKE_CASE :      str       =   self.pad(
            UpperCAmelCase__				,				padding=UpperCAmelCase__				,				max_length=UpperCAmelCase__				,				truncation=UpperCAmelCase__				,				pad_to_multiple_of=UpperCAmelCase__				,				return_attention_mask=UpperCAmelCase__				,				**UpperCAmelCase__				,				)

        # make sure list is in array format
        SCREAMING_SNAKE_CASE :      Dict       =   padded_inputs.get("""input_features"""		)
        if isinstance(input_features[0]				,				UpperCAmelCase__		):
              SCREAMING_SNAKE_CASE :      Union[str, Any]       =   [np.asarray(UpperCAmelCase__				,				dtype=np.floataa		) for feature in input_features]

        SCREAMING_SNAKE_CASE :      Dict       =   padded_inputs.get("""attention_mask"""		)
        if attention_mask is not None:
              SCREAMING_SNAKE_CASE :      int       =   [np.asarray(UpperCAmelCase__				,				dtype=np.intaa		) for array in attention_mask]

        # Utterance-level cepstral mean and variance normalization
        if self.do_ceptral_normalize:
              SCREAMING_SNAKE_CASE :      Tuple       =   (
                  np.array(UpperCAmelCase__				,				dtype=np.intaa		)
                  if self._get_padding_strategies(UpperCAmelCase__				,				max_length=UpperCAmelCase__		) is not PaddingStrategy.DO_NOT_PAD
                  else None
              )
              SCREAMING_SNAKE_CASE :      str       =   self.normalize(
                  padded_inputs["""input_features"""]				,				attention_mask=UpperCAmelCase__		)

        if return_tensors is not None:
              SCREAMING_SNAKE_CASE :      Any       =   padded_inputs.convert_to_tensors(UpperCAmelCase__		)

        return padded_inputs




