
'''simple docstring'''







from copy import deepcopy


class 						__UpperCAmelCase      :


							def __init__(       self    ,   lowerCAmelCase_ = None    ,   lowerCAmelCase_ = None  ):





								"""simple docstring"""






								if arr is None and size is not None:
									_snake_case   						=		size
									_snake_case   						=		[0] * size
								elif arr is not None:
									self.init(lowerCAmelCase_  )
								else:
									raise ValueError('Either arr or size must be specified'  )


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								_snake_case   						=		len(lowerCAmelCase_  )
								_snake_case   						=		deepcopy(lowerCAmelCase_  )
								for i in range(1    ,   self.size  ):
									_snake_case   						=		self.next_(lowerCAmelCase_  )
									if j < self.size:
										self.tree[j] += self.tree[i]


							def  lowerCamelCase				(       self  ):





								"""simple docstring"""






								_snake_case   						=		self.tree[:]
								for i in range(self.size - 1    ,   0    ,   -1  ):
									_snake_case   						=		self.next_(lowerCAmelCase_  )
									if j < self.size:
										arr[j] -= arr[i]
								return arr


							@staticmethod
							def  lowerCamelCase				(       lowerCAmelCase_  ):





								"""simple docstring"""






								return index + (index & (-index))


							@staticmethod
							def  lowerCamelCase				(       lowerCAmelCase_  ):





								"""simple docstring"""






								return index - (index & (-index))


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								if index == 0:
									self.tree[0] += value
									return
								while index < self.size:
									self.tree[index] += value
									_snake_case   						=		self.next_(lowerCAmelCase_  )


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								self.add(lowerCAmelCase_    ,   value - self.get(lowerCAmelCase_  )  )


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								if right == 0:
									return 0
								_snake_case   						=		self.tree[0]
								right -= 1  # make right inclusive
								while right > 0:
									result += self.tree[right]
									_snake_case   						=		self.prev(lowerCAmelCase_  )
								return result


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								return self.prefix(lowerCAmelCase_  ) - self.prefix(lowerCAmelCase_  )


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								return self.query(lowerCAmelCase_    ,   index + 1  )




							def  lowerCamelCase				(       self    ,   lowerCAmelCase_  ):





								"""simple docstring"""






								value -= self.tree[0]
								if value < 0:
									return -1

								_snake_case   						=		1  # Largest power of 2 <= size
								while j * 2 < self.size:
									j *= 2

								_snake_case   						=		0

								while j > 0:
									if i + j < self.size and self.tree[i + j] <= value:
										value -= self.tree[i + j]
										i += j
									j //= 2
								return i


if __name__ == "__main__":
					import doctest

					doctest.testmod()









import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin
class     a    ( lowercase__   ):



      """simple docstring"""


      a  : List[str]							       =	'MCTCTFeatureExtractor'
      a  : str							       =	'AutoTokenizer'
      def __init__(      self					:			Tuple		,      __lowercase					:			int		,      __lowercase					:			Dict					)							->      Any:
        super().__init__(__lowercase		,      __lowercase					)
        __UpperCAmelCase							:	Optional[Any]           =  self.feature_extractor
        __UpperCAmelCase							:	Optional[int]           =  False
      def __call__(      self					:			int		,      *__lowercase					:			Tuple		,      **__lowercase					:			Optional[int]					)							->      Union[str, Any]:
        # For backward compatibility
        if self._in_target_context_manager:
          return self.current_processor(*__lowercase		,      **__lowercase					)

        if "raw_speech" in kwargs:
          warnings.warn("""Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."""					)
          __UpperCAmelCase							:	Dict           =  kwargs.pop("""raw_speech"""					)
        else:
          __UpperCAmelCase							:	Dict           =  kwargs.pop("""audio"""		,      __lowercase					)
        __UpperCAmelCase							:	List[str]           =  kwargs.pop("""sampling_rate"""		,      __lowercase					)
        __UpperCAmelCase							:	Tuple           =  kwargs.pop("""text"""		,      __lowercase					)
        if len(__lowercase					) > 0:
          __UpperCAmelCase							:	Tuple           =  args[0]
          __UpperCAmelCase							:	str           =  args[1:]

        if audio is None and text is None:
          raise ValueError("""You need to specify either an `audio` or `text` input to process."""					)

        if audio is not None:
          __UpperCAmelCase							:	Tuple           =  self.feature_extractor(__lowercase		,      *__lowercase		,      sampling_rate=__lowercase		,      **__lowercase					)
        if text is not None:
          __UpperCAmelCase							:	str           =  self.tokenizer(__lowercase		,      **__lowercase					)

        if text is None:
          return inputs
        elif audio is None:
          return encodings
        else:
          __UpperCAmelCase							:	Dict           =  encodings["""input_ids"""]
          return inputs
      def 	UpperCAmelCase      (      self					:			Optional[Any]		,      *__lowercase					:			List[Any]		,      **__lowercase					:			int					)							->      List[Any]:
        return self.tokenizer.batch_decode(*__lowercase		,      **__lowercase					)
      def 	UpperCAmelCase      (      self					:			Optional[int]		,      *__lowercase					:			Optional[Any]		,      **__lowercase					:			List[str]					)							->      int:
        # For backward compatibility
        if self._in_target_context_manager:
          return self.current_processor.pad(*__lowercase		,      **__lowercase					)

        __UpperCAmelCase							:	Optional[int]           =  kwargs.pop("""input_features"""		,      __lowercase					)
        __UpperCAmelCase							:	Optional[Any]           =  kwargs.pop("""labels"""		,      __lowercase					)
        if len(__lowercase					) > 0:
          __UpperCAmelCase							:	Union[str, Any]           =  args[0]
          __UpperCAmelCase							:	str           =  args[1:]

        if input_features is not None:
          __UpperCAmelCase							:	Any           =  self.feature_extractor.pad(__lowercase		,      *__lowercase		,      **__lowercase					)
        if labels is not None:
          __UpperCAmelCase							:	Union[str, Any]           =  self.tokenizer.pad(__lowercase		,      **__lowercase					)

        if labels is None:
          return input_features
        elif input_features is None:
          return labels
        else:
          __UpperCAmelCase							:	Any           =  labels["""input_ids"""]
          return input_features
      def 	UpperCAmelCase      (      self					:			Any		,      *__lowercase					:			Union[str, Any]		,      **__lowercase					:			Dict					)							->      List[Any]:
        return self.tokenizer.decode(*__lowercase		,      **__lowercase					)




      @contextmanager
      def 	UpperCAmelCase      (      self					:			Optional[Any]					)							->      Tuple:
        warnings.warn(
            """`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your """
            """labels by using the argument `text` of the regular `__call__` method (either in the same call as """
            """your audio inputs, or in a separate call."""					)
        __UpperCAmelCase							:	Any           =  True
        __UpperCAmelCase							:	Optional[int]           =  self.tokenizer
        yield
        __UpperCAmelCase							:	List[Any]           =  self.feature_extractor
        __UpperCAmelCase							:	int           =  False


