






"""simple docstring"""



import numpy as np

from transformers import BatchFeature
from transformers.testing_utils import require_tf, require_torch

from .test_feature_extraction_common import FeatureExtractionSavingTestMixin




class 			lowerCAmelCase__			(    __magic_name__   ):
   # to overwrite at feature extractactor specific tests
   SCREAMING_SNAKE_CASE_    =None
   SCREAMING_SNAKE_CASE_    =None
   @property
   def       __a							(		self      :	Optional[int]							):


        '''simple docstring'''
        return self.feat_extract_tester.prepare_feat_extract_dict()
   def       __a							(		self      :	Dict							):


        '''simple docstring'''
        UpperCAmelCase__						:    str							=							self.feature_extraction_class(**self.feat_extract_dict							)
        self.assertTrue(hasattr(snake_case__							,			"feature_size"							)							)
        self.assertTrue(hasattr(snake_case__							,			"sampling_rate"							)							)
        self.assertTrue(hasattr(snake_case__							,			"padding_value"							)							)
   def       __a							(		self      :	List[Any]							):


        '''simple docstring'''
        UpperCAmelCase__						:    str							=							self.feat_extract_tester.prepare_inputs_for_common()
        UpperCAmelCase__						:    Union[str, Any]							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    List[Any]							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    Optional[int]							=							BatchFeature({input_name: speech_inputs}							)

        self.assertTrue(all(len(snake_case__							) == len(snake_case__							) for x, y in zip(snake_case__							,			processed_features[input_name]							)							)							)

        UpperCAmelCase__						:    Dict							=							self.feat_extract_tester.prepare_inputs_for_common(equal_length=snake_case__							)
        UpperCAmelCase__						:    List[Any]							=							BatchFeature({input_name: speech_inputs}							,			tensor_type="np"							)

        UpperCAmelCase__						:    Optional[Any]							=							processed_features[input_name]

        if len(batch_features_input.shape							) < 3:
             UpperCAmelCase__						:    Optional[Any]							=							batch_features_input[:, :, None]

        self.assertTrue(
            batch_features_input.shape
            == (self.feat_extract_tester.batch_size, len(speech_inputs[0]							), self.feat_extract_tester.feature_size)							)
   @require_torch
   def       __a							(		self      :	Tuple							):


        '''simple docstring'''
        UpperCAmelCase__						:    Optional[int]							=							self.feat_extract_tester.prepare_inputs_for_common(equal_length=snake_case__							)
        UpperCAmelCase__						:    str							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    List[str]							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    int							=							BatchFeature({input_name: speech_inputs}							,			tensor_type="pt"							)

        UpperCAmelCase__						:    Any							=							processed_features[input_name]

        if len(batch_features_input.shape							) < 3:
             UpperCAmelCase__						:    List[Any]							=							batch_features_input[:, :, None]

        self.assertTrue(
            batch_features_input.shape
            == (self.feat_extract_tester.batch_size, len(speech_inputs[0]							), self.feat_extract_tester.feature_size)							)
   @require_tf
   def       __a							(		self      :	List[Any]							):


        '''simple docstring'''
        UpperCAmelCase__						:    List[Any]							=							self.feat_extract_tester.prepare_inputs_for_common(equal_length=snake_case__							)
        UpperCAmelCase__						:    Tuple							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    List[Any]							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    Union[str, Any]							=							BatchFeature({input_name: speech_inputs}							,			tensor_type="tf"							)

        UpperCAmelCase__						:    Any							=							processed_features[input_name]

        if len(batch_features_input.shape							) < 3:
             UpperCAmelCase__						:    List[str]							=							batch_features_input[:, :, None]

        self.assertTrue(
            batch_features_input.shape
            == (self.feat_extract_tester.batch_size, len(speech_inputs[0]							), self.feat_extract_tester.feature_size)							)
   def       __a							(		self      :	Optional[Any]							,			snake_case__      :	Optional[Any]=False							):


        '''simple docstring'''
        def _inputs_have_equal_length(snake_case__      :	Dict							):
             UpperCAmelCase__						:    List[Any]							=							len(input[0]							)
             for input_slice in input[1:]:
                  if len(snake_case__							) != length:
                       return False
             return True

        def _inputs_are_equal(snake_case__      :	List[str]							,			snake_case__      :	Union[str, Any]							):
             if len(snake_case__							) != len(snake_case__							):
                  return False

             for input_slice_a, input_slice_a in zip(snake_case__							,			snake_case__							):
                  if not np.allclose(np.asarray(snake_case__							)							,			np.asarray(snake_case__							)							,			atol=1e-3							):
                       return False
             return True

        UpperCAmelCase__						:    Optional[Any]							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    Union[str, Any]							=							self.feat_extract_tester.prepare_inputs_for_common(numpify=snake_case__							)
        UpperCAmelCase__						:    Optional[Any]							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    Dict							=							BatchFeature({input_name: speech_inputs}							)

        UpperCAmelCase__						:    Any							=							self.feat_extract_tester.seq_length_diff
        UpperCAmelCase__						:    List[str]							=							self.feat_extract_tester.max_seq_length + pad_diff
        UpperCAmelCase__						:    Optional[int]							=							self.feat_extract_tester.min_seq_length
        UpperCAmelCase__						:    Optional[Any]							=							self.feat_extract_tester.batch_size
        UpperCAmelCase__						:    str							=							self.feat_extract_tester.feature_size

        # test padding for List[int] + numpy
        UpperCAmelCase__						:    Dict							=							feat_extract.pad(snake_case__							,			padding=snake_case__							)
        UpperCAmelCase__						:    Union[str, Any]							=							input_a[input_name]

        UpperCAmelCase__						:    Any							=							feat_extract.pad(snake_case__							,			padding="longest"							)
        UpperCAmelCase__						:    Dict							=							input_a[input_name]

        UpperCAmelCase__						:    Union[str, Any]							=							feat_extract.pad(snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[-1]							)							)
        UpperCAmelCase__						:    Dict							=							input_a[input_name]

        UpperCAmelCase__						:    Dict							=							feat_extract.pad(snake_case__							,			padding="longest"							,			return_tensors="np"							)
        UpperCAmelCase__						:    Optional[Any]							=							input_a[input_name]

        # max_length parameter has to be provided when setting `padding="max_length"`
        with self.assertRaises(snake_case__							):
             feat_extract.pad(snake_case__							,			padding="max_length"							)[input_name]

        UpperCAmelCase__						:    Union[str, Any]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=snake_case__							,			return_tensors="np"							)
        UpperCAmelCase__						:    Tuple							=							input_a[input_name]

        self.assertFalse(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(_inputs_are_equal(snake_case__							,			snake_case__							)							)
        self.assertTrue(len(input_a[0]							) == pad_min_length							)
        self.assertTrue(len(input_a[1]							) == pad_min_length + pad_diff							)
        self.assertTrue(input_a.shape[:2] == (batch_size, len(input_a[0]							))							)
        self.assertTrue(input_a.shape[:2] == (batch_size, pad_max_length)							)

        if feature_size > 1:
             self.assertTrue(input_a.shape[2] == input_a.shape[2] == feature_size							)

        # test padding for `pad_to_multiple_of` for List[int] + numpy
        UpperCAmelCase__						:    List[Any]							=							feat_extract.pad(snake_case__							,			pad_to_multiple_of=1_0							)
        UpperCAmelCase__						:    Optional[Any]							=							input_a[input_name]

        UpperCAmelCase__						:    str							=							feat_extract.pad(snake_case__							,			padding="longest"							,			pad_to_multiple_of=1_0							)
        UpperCAmelCase__						:    Any							=							input_a[input_name]

        UpperCAmelCase__						:    List[str]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			pad_to_multiple_of=1_0							,			max_length=snake_case__							)
        UpperCAmelCase__						:    List[str]							=							input_a[input_name]

        UpperCAmelCase__						:    Optional[Any]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			pad_to_multiple_of=1_0							,			max_length=snake_case__							,			return_tensors="np"							,			)
        UpperCAmelCase__						:    Dict							=							input_a[input_name]

        self.assertTrue(all(len(snake_case__							) % 1_0 == 0 for x in input_a							)							)
        self.assertTrue(_inputs_are_equal(snake_case__							,			snake_case__							)							)

        UpperCAmelCase__						:    int							=							pad_max_length if pad_max_length % 1_0 == 0 else (pad_max_length // 1_0 + 1) * 1_0
        self.assertTrue(all(len(snake_case__							) == expected_mult_pad_length for x in input_a							)							)
        self.assertEqual(input_a.shape[:2]							,			(batch_size, expected_mult_pad_length)							)

        if feature_size > 1:
             self.assertTrue(input_a.shape[2] == feature_size							)

        # Check padding value is correct
        UpperCAmelCase__						:    Any							=							(np.ones(self.feat_extract_tester.feature_size							) * feat_extract.padding_value).sum()
        self.assertTrue(
            abs(np.asarray(input_a[0]							)[pad_min_length:].sum() - padding_vector_sum * (pad_max_length - pad_min_length)							)
            < 1e-3							)
        self.assertTrue(
            abs(
                np.asarray(input_a[1]							)[pad_min_length + pad_diff :].sum()
                - padding_vector_sum * (pad_max_length - pad_min_length - pad_diff)							)
            < 1e-3							)
        self.assertTrue(
            abs(
                np.asarray(input_a[2]							)[pad_min_length + 2 * pad_diff :].sum()
                - padding_vector_sum * (pad_max_length - pad_min_length - 2 * pad_diff)							)
            < 1e-3							)
        self.assertTrue(
            abs(input_a[0, pad_min_length:].sum() - padding_vector_sum * (pad_max_length - pad_min_length)							) < 1e-3							)
        self.assertTrue(
            abs(input_a[0, pad_min_length:].sum() - padding_vector_sum * (expected_mult_pad_length - pad_min_length)							)
            < 1e-3							)
   def       __a							(		self      :	List[str]							,			snake_case__      :	Tuple=False							):


        '''simple docstring'''
        def _inputs_have_equal_length(snake_case__      :	Union[str, Any]							):
             UpperCAmelCase__						:    Any							=							len(input[0]							)
             for input_slice in input[1:]:
                  if len(snake_case__							) != length:
                       return False
             return True

        def _inputs_are_equal(snake_case__      :	Optional[Any]							,			snake_case__      :	Optional[int]							):
             if len(snake_case__							) != len(snake_case__							):
                  return False

             for input_slice_a, input_slice_a in zip(snake_case__							,			snake_case__							):
                  if not np.allclose(np.asarray(snake_case__							)							,			np.asarray(snake_case__							)							,			atol=1e-3							):
                       return False
             return True

        UpperCAmelCase__						:    Union[str, Any]							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    List[Any]							=							self.feat_extract_tester.prepare_inputs_for_common(numpify=snake_case__							)
        UpperCAmelCase__						:    Optional[int]							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    Optional[int]							=							BatchFeature({input_name: speech_inputs}							)

        # truncate to smallest
        UpperCAmelCase__						:    Dict							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[0]							)							,			truncation=snake_case__							)
        UpperCAmelCase__						:    Union[str, Any]							=							input_a[input_name]

        UpperCAmelCase__						:    List[Any]							=							feat_extract.pad(snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[0]							)							)
        UpperCAmelCase__						:    Tuple							=							input_a[input_name]

        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertFalse(_inputs_have_equal_length(snake_case__							)							)

        # truncate to smallest with np
        UpperCAmelCase__						:    Tuple							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[0]							)							,			return_tensors="np"							,			truncation=snake_case__							,			)
        UpperCAmelCase__						:    Optional[int]							=							input_a[input_name]

        UpperCAmelCase__						:    int							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[0]							)							,			return_tensors="np"							)
        UpperCAmelCase__						:    Optional[int]							=							input_a[input_name]

        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(input_a.shape[1] == len(speech_inputs[0]							)							)

        # since truncation forces padding to be smaller than longest input
        # function can't return `np.ndarray`, but has to return list
        self.assertFalse(_inputs_have_equal_length(snake_case__							)							)

        # truncate to middle
        UpperCAmelCase__						:    List[str]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[1]							)							,			truncation=snake_case__							,			return_tensors="np"							,			)
        UpperCAmelCase__						:    int							=							input_a[input_name]

        UpperCAmelCase__						:    Optional[int]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[1]							)							,			truncation=snake_case__							)
        UpperCAmelCase__						:    Tuple							=							input_a[input_name]

        UpperCAmelCase__						:    int							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[1]							)							,			return_tensors="np"							)
        UpperCAmelCase__						:    Tuple							=							input_a[input_name]

        self.assertTrue(input_a.shape[1] == len(speech_inputs[1]							)							)
        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(_inputs_are_equal(snake_case__							,			snake_case__							)							)

        # since truncation forces padding to be smaller than longest input
        # function can't return `np.ndarray`, but has to return list
        self.assertFalse(_inputs_have_equal_length(snake_case__							)							)
        self.assertTrue(len(input_a[-1]							) == len(speech_inputs[-1]							)							)

        # padding has to be max_length when setting `truncation=True`
        with self.assertRaises(snake_case__							):
             feat_extract.pad(snake_case__							,			truncation=snake_case__							)[input_name]

        # padding has to be max_length when setting `truncation=True`
        with self.assertRaises(snake_case__							):
             feat_extract.pad(snake_case__							,			padding="longest"							,			truncation=snake_case__							)[input_name]

        # padding has to be max_length when setting `truncation=True`
        with self.assertRaises(snake_case__							):
             feat_extract.pad(snake_case__							,			padding="longest"							,			truncation=snake_case__							)[input_name]

        # max_length parameter has to be provided when setting `truncation=True` and padding="max_length"
        with self.assertRaises(snake_case__							):
             feat_extract.pad(snake_case__							,			padding="max_length"							,			truncation=snake_case__							)[input_name]

        # test truncation for `pad_to_multiple_of` for List[int] + numpy
        UpperCAmelCase__						:    str							=							1_2
        UpperCAmelCase__						:    List[str]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[0]							)							,			pad_to_multiple_of=snake_case__							,			truncation=snake_case__							,			)
        UpperCAmelCase__						:    Union[str, Any]							=							input_a[input_name]

        UpperCAmelCase__						:    str							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=len(speech_inputs[0]							)							,			pad_to_multiple_of=snake_case__							,			)
        UpperCAmelCase__						:    Union[str, Any]							=							input_a[input_name]

        # retrieve expected_length as multiple of pad_to_multiple_of
        UpperCAmelCase__						:    Dict							=							len(speech_inputs[0]							)
        if expected_length % pad_to_multiple_of != 0:
             UpperCAmelCase__						:    int							=							((len(speech_inputs[0]							) // pad_to_multiple_of) + 1) * pad_to_multiple_of

        self.assertTrue(len(input_a[0]							) == expected_length							)
        self.assertTrue(_inputs_have_equal_length(snake_case__							)							)
        self.assertFalse(_inputs_have_equal_length(snake_case__							)							)
   def       __a							(		self      :	Dict							):


        '''simple docstring'''
        self._check_padding(numpify=snake_case__							)
   def       __a							(		self      :	Union[str, Any]							):


        '''simple docstring'''
        self._check_padding(numpify=snake_case__							)
   def       __a							(		self      :	Any							):


        '''simple docstring'''
        self._check_truncation(numpify=snake_case__							)
   def       __a							(		self      :	Union[str, Any]							):


        '''simple docstring'''
        self._check_truncation(numpify=snake_case__							)
   @require_torch
   def       __a							(		self      :	List[str]							):


        '''simple docstring'''
        UpperCAmelCase__						:    Any							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    Optional[int]							=							self.feat_extract_tester.prepare_inputs_for_common()
        UpperCAmelCase__						:    Tuple							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    int							=							BatchFeature({input_name: speech_inputs}							)

        UpperCAmelCase__						:    Optional[Any]							=							feat_extract.pad(snake_case__							,			padding="longest"							,			return_tensors="np"							)[input_name]
        UpperCAmelCase__						:    List[str]							=							feat_extract.pad(snake_case__							,			padding="longest"							,			return_tensors="pt"							)[input_name]

        self.assertTrue(abs(input_np.astype(np.floataa							).sum() - input_pt.numpy().astype(np.floataa							).sum()							) < 1e-2							)
   @require_tf
   def       __a							(		self      :	int							):


        '''simple docstring'''
        UpperCAmelCase__						:    List[Any]							=							self.feature_extraction_class(**self.feat_extract_dict							)
        UpperCAmelCase__						:    str							=							self.feat_extract_tester.prepare_inputs_for_common()
        UpperCAmelCase__						:    Any							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    Dict							=							BatchFeature({input_name: speech_inputs}							)

        UpperCAmelCase__						:    List[Any]							=							feat_extract.pad(snake_case__							,			padding="longest"							,			return_tensors="np"							)[input_name]
        UpperCAmelCase__						:    List[Any]							=							feat_extract.pad(snake_case__							,			padding="longest"							,			return_tensors="tf"							)[input_name]

        self.assertTrue(abs(input_np.astype(np.floataa							).sum() - input_tf.numpy().astype(np.floataa							).sum()							) < 1e-2							)
   def       __a							(		self      :	Optional[Any]							):


        '''simple docstring'''
        UpperCAmelCase__						:    List[str]							=							self.feat_extract_dict
        UpperCAmelCase__						:    Dict							=							True
        UpperCAmelCase__						:    List[str]							=							self.feature_extraction_class(**snake_case__							)
        UpperCAmelCase__						:    Tuple							=							self.feat_extract_tester.prepare_inputs_for_common()
        UpperCAmelCase__						:    Tuple							=							[len(snake_case__							) for x in speech_inputs]
        UpperCAmelCase__						:    Union[str, Any]							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    Union[str, Any]							=							BatchFeature({input_name: speech_inputs}							)

        UpperCAmelCase__						:    int							=							feat_extract.pad(snake_case__							,			padding="longest"							,			return_tensors="np"							)
        self.assertIn("attention_mask"							,			snake_case__							)
        self.assertListEqual(list(processed.attention_mask.shape							)							,			list(processed[input_name].shape[:2]							)							)
        self.assertListEqual(processed.attention_mask.sum(-1							).tolist()							,			snake_case__							)




   def       __a							(		self      :	Optional[Any]							):


        '''simple docstring'''
        UpperCAmelCase__						:    int							=							self.feat_extract_dict
        UpperCAmelCase__						:    List[str]							=							True
        UpperCAmelCase__						:    Optional[Any]							=							self.feature_extraction_class(**snake_case__							)
        UpperCAmelCase__						:    Any							=							self.feat_extract_tester.prepare_inputs_for_common()
        UpperCAmelCase__						:    Tuple							=							[len(snake_case__							) for x in speech_inputs]
        UpperCAmelCase__						:    Dict							=							feat_extract.model_input_names[0]

        UpperCAmelCase__						:    int							=							BatchFeature({input_name: speech_inputs}							)
        UpperCAmelCase__						:    int							=							min(snake_case__							)

        UpperCAmelCase__						:    List[Any]							=							feat_extract.pad(
            snake_case__							,			padding="max_length"							,			max_length=snake_case__							,			truncation=snake_case__							,			return_tensors="np"							)
        self.assertIn("attention_mask"							,			snake_case__							)
        self.assertListEqual(
            list(processed_pad.attention_mask.shape							)							,			[processed_pad[input_name].shape[0], max_length]							)
        self.assertListEqual(
            processed_pad.attention_mask[:, :max_length].sum(-1							).tolist()							,			[max_length for x in speech_inputs]							)










"""simple docstring"""



import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


_lowerCAmelCase	:	Union[str, Any]				=      threading.Lock()
_lowerCAmelCase	:	Optional[logging.Handler]				=      None

_lowerCAmelCase	:	Union[str, Any]				=      {
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

_lowerCAmelCase	:	Dict				=      logging.WARNING

_lowerCAmelCase	:	Optional[Any]				=      True


def 	SCREAMING_SNAKE_CASE__       (  )->		List[str]:






     '''simple docstring'''



     UpperCAmelCase__						:    Union[str, Any]							=							os.getenv("TRANSFORMERS_VERBOSITY"			,					snake_case				)
     if env_level_str:
          if env_level_str in log_levels:
               return log_levels[env_level_str]
          else:
               logging.getLogger().warning(
                   f'Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, '
                   f'has to be one of: { ", ".join(log_levels.keys()				) }'				)
     return _default_log_level


def 	SCREAMING_SNAKE_CASE__       (  )->		str:






     '''simple docstring'''



     return __name__.split("."				)[0]


def 	SCREAMING_SNAKE_CASE__       (  )->		logging.Logger:






     '''simple docstring'''



     return logging.getLogger(_get_library_name()				)


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     global _default_handler

     with _lock:
          if _default_handler:
               # This library has already configured the library root logger.
               return
          UpperCAmelCase__						:    Any							=							logging.StreamHandler()  # Set sys.stderr as stream.
          UpperCAmelCase__						:    Union[str, Any]							=							sys.stderr.flush

          # Apply our default configuration to the library root logger.
          UpperCAmelCase__						:    Union[str, Any]							=							_get_library_root_logger()
          library_root_logger.addHandler(_default_handler				)
          library_root_logger.setLevel(_get_default_logging_level()				)
          UpperCAmelCase__						:    int							=							False


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     global _default_handler

     with _lock:
          if not _default_handler:
               return

          UpperCAmelCase__						:    Union[str, Any]							=							_get_library_root_logger()
          library_root_logger.removeHandler(_default_handler				)
          library_root_logger.setLevel(logging.NOTSET				)
          UpperCAmelCase__						:    Optional[int]							=							None


def 	SCREAMING_SNAKE_CASE__       (  )->		Optional[int]:






     '''simple docstring'''



     return log_levels


def 	SCREAMING_SNAKE_CASE__       (  snake_case       : Optional[str] = None				)->		logging.Logger:






     '''simple docstring'''



     if name is None:
          UpperCAmelCase__						:    Tuple							=							_get_library_name()

     _configure_library_root_logger()
     return logging.getLogger(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		int:






     '''simple docstring'''



     _configure_library_root_logger()
     return _get_library_root_logger().getEffectiveLevel()


def 	SCREAMING_SNAKE_CASE__       (  snake_case       : int				)->		None:






     '''simple docstring'''



     _configure_library_root_logger()
     _get_library_root_logger().setLevel(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		Optional[Any]:






     '''simple docstring'''



     return set_verbosity(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		List[str]:






     '''simple docstring'''



     return set_verbosity(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		Tuple:






     '''simple docstring'''



     return set_verbosity(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		str:






     '''simple docstring'''



     return set_verbosity(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     _configure_library_root_logger()

     assert _default_handler is not None
     _get_library_root_logger().removeHandler(_default_handler				)


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     _configure_library_root_logger()

     assert _default_handler is not None
     _get_library_root_logger().addHandler(_default_handler				)


def 	SCREAMING_SNAKE_CASE__       (  snake_case       : logging.Handler				)->		None:






     '''simple docstring'''



     _configure_library_root_logger()

     assert handler is not None
     _get_library_root_logger().addHandler(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  snake_case       : logging.Handler				)->		None:






     '''simple docstring'''



     _configure_library_root_logger()

     assert handler is not None and handler not in _get_library_root_logger().handlers
     _get_library_root_logger().removeHandler(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     _configure_library_root_logger()
     UpperCAmelCase__						:    Dict							=							False


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     _configure_library_root_logger()
     UpperCAmelCase__						:    List[Any]							=							True


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     UpperCAmelCase__						:    Union[str, Any]							=							_get_library_root_logger().handlers

     for handler in handlers:
          UpperCAmelCase__						:    Union[str, Any]							=							logging.Formatter("[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"				)
          handler.setFormatter(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  )->		None:






     '''simple docstring'''



     UpperCAmelCase__						:    Any							=							_get_library_root_logger().handlers

     for handler in handlers:
          handler.setFormatter(snake_case				)


def 	SCREAMING_SNAKE_CASE__       (  self       : Optional[int]			,					*snake_case       : List[str]			,					**snake_case       : str				)->		Union[str, Any]:






     '''simple docstring'''



     UpperCAmelCase__						:    Union[str, Any]							=							os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS"			,					snake_case				)
     if no_advisory_warnings:
          return
     self.warning(*snake_case			,					**snake_case				)


_lowerCAmelCase	:	int				=      warning_advice


@functools.lru_cache(snake_case				)
def 	SCREAMING_SNAKE_CASE__       (  self       : Optional[Any]			,					*snake_case       : Dict			,					**snake_case       : Any				)->		Any:






     '''simple docstring'''



     self.warning(*snake_case			,					**snake_case				)


_lowerCAmelCase	:	Tuple				=      warning_once




class 			lowerCAmelCase__			:
   def __init__(		self      :	List[str]							,			*snake_case__      :	Any							,			**snake_case__      :	List[str]							):  # pylint: disable=unused-argument


        '''simple docstring'''
        UpperCAmelCase__						:    List[Any]							=							args[0] if args else None
   def __iter__(		self      :	Any							):


        '''simple docstring'''
        return iter(self._iterator							)
   def __getattr__(		self      :	List[Any]							,			snake_case__      :	Tuple							):


        '''simple docstring'''

        def empty_fn(*snake_case__      :	Dict							,			**snake_case__      :	str							):  # pylint: disable=unused-argument
             return

        return empty_fn
   def __enter__(		self      :	Optional[Any]							):


        '''simple docstring'''
        return self




   def __exit__(		self      :	Tuple							,			snake_case__      :	Tuple							,			snake_case__      :	Any							,			snake_case__      :	Optional[int]							):


        '''simple docstring'''
        return




class 			lowerCAmelCase__			:
   def __call__(		self      :	Optional[Any]							,			*snake_case__      :	Optional[Any]							,			**snake_case__      :	Tuple							):


        '''simple docstring'''
        if _tqdm_active:
             return tqdm_lib.tqdm(*snake_case__							,			**snake_case__							)
        else:
             return EmptyTqdm(*snake_case__							,			**snake_case__							)
   def       __a							(		self      :	Dict							,			*snake_case__      :	List[str]							,			**snake_case__      :	Union[str, Any]							):


        '''simple docstring'''
        UpperCAmelCase__						:    Dict							=							None
        if _tqdm_active:
             return tqdm_lib.tqdm.set_lock(*snake_case__							,			**snake_case__							)




   def       __a							(		self      :	Tuple							):


        '''simple docstring'''
        if _tqdm_active:
             return tqdm_lib.tqdm.get_lock()




_lowerCAmelCase	:	Optional[int]				=      _tqdm_cls()


def 	SCREAMING_SNAKE_CASE__       (  )->		bool:






     '''simple docstring'''



     global _tqdm_active
     return bool(_tqdm_active				)


def 	SCREAMING_SNAKE_CASE__       (  )->		List[Any]:






     '''simple docstring'''



     global _tqdm_active
     UpperCAmelCase__						:    int							=							True
     hf_hub_utils.enable_progress_bars()



def 	SCREAMING_SNAKE_CASE__       (  )->		List[Any]:






     '''simple docstring'''



     global _tqdm_active
     UpperCAmelCase__						:    Optional[Any]							=							False
     hf_hub_utils.disable_progress_bars()


