



import itertools
import random
import unittest

import numpy as np

from transformers import BatchFeature, SpeechTaFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
							import torch


SCREAMING_SNAKE_CASE__       =      random.Random()


def A						(       __UpperCamelCase ,	__UpperCamelCase=1.0 ,	__UpperCamelCase=None ,	__UpperCamelCase=None					)						->      Any:
			if rng is None:
						A__       =    global_rng

			A__       =    []
			for batch_idx in range(shape[0]					):
						values.append([]					)
						for _ in range(shape[1]					):
									values[-1].append(rng.random() * scale					)

			return values


@require_torch
class      __lowerCAmelCase     (		unittest.TestCase      ):
					"""simple docstring"""






					def __init__(     self					:       Any				,					_snake_case					:       Union[str, Any]				,					_snake_case					:       Tuple=7				,					_snake_case					:       Tuple=4_00				,					_snake_case					:       Any=20_00				,					_snake_case					:       Dict=1				,					_snake_case					:       int=0.0				,					_snake_case					:       List[str]=1_60_00				,					_snake_case					:       Dict=True				,					_snake_case					:       Dict=80				,					_snake_case					:       List[str]=16				,					_snake_case					:       Union[str, Any]=64				,					_snake_case					:       Optional[Any]="hann_window"				,					_snake_case					:       Any=80				,					_snake_case					:       Tuple=76_00				,					_snake_case					:       Any=1E-10				,					_snake_case					:       str=True				,					):






								"""simple docstring"""


								A__       =    parent
								A__       =    batch_size
								A__       =    min_seq_length
								A__       =    max_seq_length
								A__       =    (self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
								A__       =    feature_size
								A__       =    padding_value
								A__       =    sampling_rate
								A__       =    do_normalize
								A__       =    num_mel_bins
								A__       =    hop_length
								A__       =    win_length
								A__       =    win_function
								A__       =    fmin
								A__       =    fmax
								A__       =    mel_floor
								A__       =    return_attention_mask



					def     _a							(     self					:       Union[str, Any]					):






								"""simple docstring"""


								return {
								    "feature_size": self.feature_size,
								    "padding_value": self.padding_value,
								    "sampling_rate": self.sampling_rate,
								    "do_normalize": self.do_normalize,
								    "num_mel_bins": self.num_mel_bins,
								    "hop_length": self.hop_length,
								    "win_length": self.win_length,
								    "win_function": self.win_function,
								    "fmin": self.fmin,
								    "fmax": self.fmax,
								    "mel_floor": self.mel_floor,
								    "return_attention_mask": self.return_attention_mask,
								}



					def     _a							(     self					:       int				,					_snake_case					:       Union[str, Any]=False				,					_snake_case					:       Union[str, Any]=False					):






								"""simple docstring"""


								def _flatten(_snake_case					:       int					):
											return list(itertools.chain(*_snake_case					)					)

								if equal_length:
											A__       =    floats_list((self.batch_size, self.max_seq_length)					)
								else:
											# make sure that inputs increase in size
											A__       =    [
											    _flatten(floats_list((x, self.feature_size)					)					)
											    for x in range(self.min_seq_length				,					self.max_seq_length				,					self.seq_length_diff					)
											]

								if numpify:
											A__       =    [np.asarray(_snake_case					) for x in speech_inputs]

								return speech_inputs



					def     _a							(     self					:       Tuple				,					_snake_case					:       Any=False				,					_snake_case					:       str=False					):






								"""simple docstring"""


								if equal_length:
											A__       =    [floats_list((self.max_seq_length, self.num_mel_bins)					) for _ in range(self.batch_size					)]
								else:
											# make sure that inputs increase in size
											A__       =    [
											    floats_list((x, self.num_mel_bins)					)
											    for x in range(self.min_seq_length				,					self.max_seq_length				,					self.seq_length_diff					)
											]

								if numpify:
											A__       =    [np.asarray(_snake_case					) for x in speech_inputs]

								return speech_inputs







@require_torch
class      __lowerCAmelCase     (		UpperCAmelCase_							,     unittest.TestCase      ):
					"""simple docstring"""






					A__				:		Dict			       =    SpeechTaFeatureExtractor



					def     _a							(     self					:       Optional[Any]					):






								"""simple docstring"""


								A__       =    SpeechTaFeatureExtractionTester(self					)



					def     _a							(     self					:       Dict				,					_snake_case					:       Any					):






								"""simple docstring"""


								self.assertTrue(np.all(np.mean(_snake_case				,					axis=0					) < 1E-3					)					)
								self.assertTrue(np.all(np.abs(np.var(_snake_case				,					axis=0					) - 1					) < 1E-3					)					)



					def     _a							(     self					:       Optional[int]					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								# create three inputs of length 800, 1000, and 1200
								A__       =    [floats_list((1, x)					)[0] for x in range(8_00				,					14_00				,					2_00					)]
								A__       =    [np.asarray(_snake_case					) for speech_input in speech_inputs]

								# Test not batched input
								A__       =    feat_extract(speech_inputs[0]				,					return_tensors='np'					).input_values
								A__       =    feat_extract(np_speech_inputs[0]				,					return_tensors='np'					).input_values
								self.assertTrue(np.allclose(_snake_case				,					_snake_case				,					atol=1E-3					)					)

								# Test batched
								A__       =    feat_extract(_snake_case				,					return_tensors='np'					).input_values
								A__       =    feat_extract(_snake_case				,					return_tensors='np'					).input_values
								for enc_seq_a, enc_seq_a in zip(_snake_case				,					_snake_case					):
											self.assertTrue(np.allclose(_snake_case				,					_snake_case				,					atol=1E-3					)					)



					def     _a							(     self					:       Optional[int]					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								A__       =    [floats_list((1, x)					)[0] for x in range(8_00				,					14_00				,					2_00					)]

								A__       =    ['longest', 'max_length', 'do_not_pad']
								A__       =    [None, 16_00, None]
								for max_length, padding in zip(_snake_case				,					_snake_case					):
											A__       =    feat_extract(_snake_case				,					padding=_snake_case				,					max_length=_snake_case				,					return_tensors='np'					)
											A__       =    processed.input_values

											self._check_zero_mean_unit_variance(input_values[0][:8_00]					)
											self.assertTrue(input_values[0][8_00:].sum() < 1E-6					)
											self._check_zero_mean_unit_variance(input_values[1][:10_00]					)
											self.assertTrue(input_values[0][10_00:].sum() < 1E-6					)
											self._check_zero_mean_unit_variance(input_values[2][:12_00]					)



					def     _a							(     self					:       List[Any]					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								A__       =    range(8_00				,					14_00				,					2_00					)
								A__       =    [floats_list((1, x)					)[0] for x in lengths]

								A__       =    ['longest', 'max_length', 'do_not_pad']
								A__       =    [None, 16_00, None]

								for max_length, padding in zip(_snake_case				,					_snake_case					):
											A__       =    feat_extract(_snake_case				,					max_length=_snake_case				,					padding=_snake_case					)
											A__       =    processed.input_values

											self._check_zero_mean_unit_variance(input_values[0][:8_00]					)
											self._check_zero_mean_unit_variance(input_values[1][:10_00]					)
											self._check_zero_mean_unit_variance(input_values[2][:12_00]					)



					def     _a							(     self					:       Optional[int]					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								A__       =    [floats_list((1, x)					)[0] for x in range(8_00				,					14_00				,					2_00					)]
								A__       =    feat_extract(
								    _snake_case				,					truncation=_snake_case				,					max_length=10_00				,					padding='max_length'				,					return_tensors='np'					)
								A__       =    processed.input_values

								self._check_zero_mean_unit_variance(input_values[0, :8_00]					)
								self._check_zero_mean_unit_variance(input_values[1]					)
								self._check_zero_mean_unit_variance(input_values[2]					)



					def     _a							(     self					:       str					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								A__       =    [floats_list((1, x)					)[0] for x in range(8_00				,					14_00				,					2_00					)]
								A__       =    feat_extract(
								    _snake_case				,					truncation=_snake_case				,					max_length=10_00				,					padding='longest'				,					return_tensors='np'					)
								A__       =    processed.input_values

								self._check_zero_mean_unit_variance(input_values[0, :8_00]					)
								self._check_zero_mean_unit_variance(input_values[1, :10_00]					)
								self._check_zero_mean_unit_variance(input_values[2]					)

								# make sure that if max_length < longest -> then pad to max_length
								self.assertTrue(input_values.shape == (3, 10_00)					)

								A__       =    [floats_list((1, x)					)[0] for x in range(8_00				,					14_00				,					2_00					)]
								A__       =    feat_extract(
								    _snake_case				,					truncation=_snake_case				,					max_length=20_00				,					padding='longest'				,					return_tensors='np'					)
								A__       =    processed.input_values

								self._check_zero_mean_unit_variance(input_values[0, :8_00]					)
								self._check_zero_mean_unit_variance(input_values[1, :10_00]					)
								self._check_zero_mean_unit_variance(input_values[2]					)

								# make sure that if max_length > longest -> then pad to longest
								self.assertTrue(input_values.shape == (3, 12_00)					)



					def     _a							(     self					:       Any					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								A__       =    np.random.rand(1_00					).astype(np.floataa					)
								A__       =    np_speech_inputs.tolist()

								for inputs in [py_speech_inputs, np_speech_inputs]:
											A__       =    feature_extractor.pad([{'input_values': inputs}]				,					return_tensors='np'					)
											self.assertTrue(np_processed.input_values.dtype == np.floataa					)
											A__       =    feature_extractor.pad([{'input_values': inputs}]				,					return_tensors='pt'					)
											self.assertTrue(pt_processed.input_values.dtype == torch.floataa					)



					def     _a							(     self					:       Dict					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()					)
								# create three inputs of length 800, 1000, and 1200
								A__       =    [floats_list((1, x)					)[0] for x in range(8_00				,					14_00				,					2_00					)]
								A__       =    [np.asarray(_snake_case					) for speech_input in speech_inputs]

								# Test feature size
								A__       =    feature_extractor(audio_target=_snake_case				,					padding=_snake_case				,					return_tensors='np'					).input_values
								self.assertTrue(input_values.ndim == 3					)
								self.assertTrue(input_values.shape[-1] == feature_extractor.num_mel_bins					)

								# Test not batched input
								A__       =    feature_extractor(speech_inputs[0]				,					return_tensors='np'					).input_values
								A__       =    feature_extractor(np_speech_inputs[0]				,					return_tensors='np'					).input_values
								self.assertTrue(np.allclose(_snake_case				,					_snake_case				,					atol=1E-3					)					)

								# Test batched
								A__       =    feature_extractor(_snake_case				,					return_tensors='np'					).input_values
								A__       =    feature_extractor(_snake_case				,					return_tensors='np'					).input_values
								for enc_seq_a, enc_seq_a in zip(_snake_case				,					_snake_case					):
											self.assertTrue(np.allclose(_snake_case				,					_snake_case				,					atol=1E-3					)					)

								# Test 2-D numpy arrays are batched.
								A__       =    [floats_list((1, x)					)[0] for x in (8_00, 8_00, 8_00)]
								A__       =    np.asarray(_snake_case					)
								A__       =    feature_extractor(_snake_case				,					return_tensors='np'					).input_values
								A__       =    feature_extractor(_snake_case				,					return_tensors='np'					).input_values
								for enc_seq_a, enc_seq_a in zip(_snake_case				,					_snake_case					):
											self.assertTrue(np.allclose(_snake_case				,					_snake_case				,					atol=1E-3					)					)



					def     _a							(     self					:       Optional[int]					):






								"""simple docstring"""


								A__       =    self.feat_extract_tester.prepare_inputs_for_target()
								A__       =    self.feature_extraction_class(**self.feat_extract_dict					)
								A__       =    feat_extract.model_input_names[0]

								A__       =    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]					)					)					)

								A__       =    self.feat_extract_tester.prepare_inputs_for_target(equal_length=_snake_case					)
								A__       =    BatchFeature({input_name: speech_inputs}				,					tensor_type='np'					)

								A__       =    processed_features[input_name]

								if len(batch_features_input.shape					) < 3:
											A__       =    batch_features_input[:, :, None]

								self.assertTrue(
								    batch_features_input.shape
								    == (self.feat_extract_tester.batch_size, len(speech_inputs[0]					), self.feat_extract_tester.num_mel_bins)					)



					@require_torch
					def     _a							(     self					:       Tuple					):






								"""simple docstring"""


								A__       =    self.feat_extract_tester.prepare_inputs_for_target(equal_length=_snake_case					)
								A__       =    self.feature_extraction_class(**self.feat_extract_dict					)
								A__       =    feat_extract.model_input_names[0]

								A__       =    BatchFeature({input_name: speech_inputs}				,					tensor_type='pt'					)

								A__       =    processed_features[input_name]

								if len(batch_features_input.shape					) < 3:
											A__       =    batch_features_input[:, :, None]

								self.assertTrue(
								    batch_features_input.shape
								    == (self.feat_extract_tester.batch_size, len(speech_inputs[0]					), self.feat_extract_tester.num_mel_bins)					)



					@require_torch
					def     _a							(     self					:       Any					):






								"""simple docstring"""


								A__       =    self.feature_extraction_class(**self.feat_extract_dict					)
								A__       =    self.feat_extract_tester.prepare_inputs_for_target()
								A__       =    feat_extract.model_input_names[0]

								A__       =    BatchFeature({input_name: speech_inputs}					)

								A__       =    feat_extract.num_mel_bins  # hack!

								A__       =    feat_extract.pad(_snake_case				,					padding='longest'				,					return_tensors='np'					)[input_name]
								A__       =    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					)



					def     _a							(     self					:       List[Any]					):






								"""simple docstring"""


								A__       =    self.feat_extract_dict
								A__       =    True
								A__       =    self.feature_extraction_class(**_snake_case					)
								A__       =    self.feat_extract_tester.prepare_inputs_for_target()
								A__       =    [len(_snake_case					) for x in speech_inputs]
								A__       =    feat_extract.model_input_names[0]

								A__       =    BatchFeature({input_name: speech_inputs}					)

								A__       =    feat_extract.num_mel_bins  # hack!

								A__       =    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					:       Any					):






								"""simple docstring"""


								A__       =    self.feat_extract_dict
								A__       =    True
								A__       =    self.feature_extraction_class(**_snake_case					)
								A__       =    self.feat_extract_tester.prepare_inputs_for_target()
								A__       =    [len(_snake_case					) for x in speech_inputs]
								A__       =    feat_extract.model_input_names[0]

								A__       =    BatchFeature({input_name: speech_inputs}					)
								A__       =    min(_snake_case					)

								A__       =    feat_extract.num_mel_bins  # hack!

								A__       =    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]					)



					def     _a							(     self					:       List[str]				,					_snake_case					:       int					):






								"""simple docstring"""


								from datasets import load_dataset

								A__       =    load_dataset('hf-internal-testing/librispeech_asr_dummy'				,					'clean'				,					split='validation'					)
								# automatic decoding with librispeech
								A__       =    ds.sort('id'					).select(range(_snake_case					)					)[:num_samples]['audio']

								return [x["array"] for x in speech_samples]



					def     _a							(     self					:       Dict					):






								"""simple docstring"""


								A__       =    torch.tensor(
								    [2.38_04E-03, 2.07_52E-03, 1.98_36E-03, 2.10_57E-03, 1.61_74E-03,
								     3.05_18E-04, 9.15_53E-05, 3.35_69E-04, 9.76_56E-04, 1.83_11E-03,
								     2.01_42E-03, 2.10_57E-03, 1.73_95E-03, 4.57_76E-04, -3.96_73E-04,
								     4.57_76E-04, 1.00_71E-03, 9.15_53E-05, 4.88_28E-04, 1.15_97E-03,
								     7.32_42E-04, 9.46_04E-04, 1.80_05E-03, 1.83_11E-03, 8.85_01E-04,
								     4.27_25E-04, 4.88_28E-04, 7.32_42E-04, 1.09_86E-03, 2.10_57E-03]					)
								# fmt: on

								A__       =    self._load_datasamples(1					)
								A__       =    SpeechTaFeatureExtractor()
								A__       =    feature_extractor(_snake_case				,					return_tensors='pt'					).input_values
								self.assertEquals(input_values.shape				,					(1, 9_36_80)					)
								self.assertTrue(torch.allclose(input_values[0, :30]				,					_snake_case				,					atol=1E-6					)					)



					def     _a							(     self					:       str					):






								"""simple docstring"""


								A__       =    torch.tensor(
								    [-2.6870, -3.0104, -3.1356, -3.5352, -3.0044, -3.0353, -3.4719, -3.6777,
								     -3.1520, -2.9435, -2.6553, -2.8795, -2.9944, -2.5921, -3.0279, -3.0386,
								     -3.0864, -3.1291, -3.2353, -2.7444, -2.6831, -2.7287, -3.1761, -3.1571,
								     -3.2726, -3.0582, -3.1007, -3.4533, -3.4695, -3.0998]					)
								# fmt: on

								A__       =    self._load_datasamples(1					)
								A__       =    SpeechTaFeatureExtractor()
								A__       =    feature_extractor(audio_target=_snake_case				,					return_tensors='pt'					).input_values
								self.assertEquals(input_values.shape				,					(1, 3_66, 80)					)
								self.assertTrue(torch.allclose(input_values[0, 0, :30]				,					_snake_case				,					atol=1E-4					)					)









import argparse
import struct
import unittest


class      __lowerCAmelCase     :
					"""simple docstring"""






					def __init__(     self					:       List[str]				,					_snake_case					:       bytes					):






								"""simple docstring"""


								A__       =    data

								# Initialize hash values
								A__       =    [
								    0x6A09E667,
								    0xBB67AE85,
								    0x3C6EF372,
								    0xA54FF53A,
								    0x510E527F,
								    0x9B05688C,
								    0x1F83D9AB,
								    0x5BE0CD19,
								]

								# Initialize round constants
								A__       =    [
								    0x428A2F98,
								    0x71374491,
								    0xB5C0FBCF,
								    0xE9B5DBA5,
								    0x3956C25B,
								    0x59F111F1,
								    0x923F82A4,
								    0xAB1C5ED5,
								    0xD807AA98,
								    0x12835B01,
								    0x243185BE,
								    0x550C7DC3,
								    0x72BE5D74,
								    0x80DEB1FE,
								    0x9BDC06A7,
								    0xC19BF174,
								    0xE49B69C1,
								    0xEFBE4786,
								    0x0FC19DC6,
								    0x240CA1CC,
								    0x2DE92C6F,
								    0x4A7484AA,
								    0x5CB0A9DC,
								    0x76F988DA,
								    0x983E5152,
								    0xA831C66D,
								    0xB00327C8,
								    0xBF597FC7,
								    0xC6E00BF3,
								    0xD5A79147,
								    0x06CA6351,
								    0x14292967,
								    0x27B70A85,
								    0x2E1B2138,
								    0x4D2C6DFC,
								    0x53380D13,
								    0x650A7354,
								    0x766A0ABB,
								    0x81C2C92E,
								    0x92722C85,
								    0xA2BFE8A1,
								    0xA81A664B,
								    0xC24B8B70,
								    0xC76C51A3,
								    0xD192E819,
								    0xD6990624,
								    0xF40E3585,
								    0x106AA070,
								    0x19A4C116,
								    0x1E376C08,
								    0x2748774C,
								    0x34B0BCB5,
								    0x391C0CB3,
								    0x4ED8AA4A,
								    0x5B9CCA4F,
								    0x682E6FF3,
								    0x748F82EE,
								    0x78A5636F,
								    0x84C87814,
								    0x8CC70208,
								    0x90BEFFFA,
								    0xA4506CEB,
								    0xBEF9A3F7,
								    0xC67178F2,
								]

								A__       =    self.preprocessing(self.data					)
								self.final_hash()



					@staticmethod
					def     _a							(     _snake_case					:       bytes					):






								"""simple docstring"""


								A__       =    B'\x80' + (B'\x00' * (63 - (len(_snake_case					) + 8) % 64))
								A__       =    struct.pack('>Q'				,					(len(_snake_case					) * 8)					)
								return data + padding + big_endian_integer



					def     _a							(     self					:       Optional[int]					):






								"""simple docstring"""


								A__       =    [
								    self.preprocessed_data[x : x + 64]
								    for x in range(0				,					len(self.preprocessed_data					)				,					64					)
								]

								for block in self.blocks:
											# Convert the given block into a list of 4 byte integers
											A__       =    list(struct.unpack('>16L'				,					_snake_case					)					)
											# add 48 0-ed integers
											words += [0] * 48

											A__     , A__     , A__     , A__     , A__     , A__     , A__     , A__       =    self.hashes

											for index in range(0				,					64					):
														if index > 15:
																	# modify the zero-ed indexes at the end of the array
																	A__       =    (
																	    self.ror(words[index - 15]				,					7					)
																	    ^ self.ror(words[index - 15]				,					18					)
																	    ^ (words[index - 15] >> 3)
																	)
																	A__       =    (
																	    self.ror(words[index - 2]				,					17					)
																	    ^ self.ror(words[index - 2]				,					19					)
																	    ^ (words[index - 2] >> 10)
																	)

																	A__       =    (
																	    words[index - 16] + sa + words[index - 7] + sa
																	) % 0x100000000

														# Compression
														A__       =    self.ror(_snake_case				,					6					) ^ self.ror(_snake_case				,					11					) ^ self.ror(_snake_case				,					25					)
														A__       =    (e & f) ^ ((~e & 0xFFFFFFFF) & g)
														A__       =    (
														    h + sa + ch + self.round_constants[index] + words[index]
														) % 0x100000000
														A__       =    self.ror(_snake_case				,					2					) ^ self.ror(_snake_case				,					13					) ^ self.ror(_snake_case				,					22					)
														A__       =    (a & b) ^ (a & c) ^ (b & c)
														A__       =    (sa + maj) % 0x100000000

														A__     , A__     , A__     , A__     , A__     , A__     , A__     , A__       =    (
														    g,
														    f,
														    e,
														    ((d + tempa) % 0x100000000),
														    c,
														    b,
														    a,
														    ((tempa + tempa) % 0x100000000),
														)

											A__       =    [a, b, c, d, e, f, g, h]

											# Modify final values
											A__       =    [
											    ((element + mutated_hash_values[index]) % 0x100000000)
											    for index, element in enumerate(self.hashes					)
											]

								A__       =    ''.join([hex(_snake_case					)[2:].zfill(8					) for value in self.hashes]					)



					def     _a							(     self					:       Dict				,					_snake_case					:       int				,					_snake_case					:       int					):






								"""simple docstring"""


								return 0xFFFFFFFF & (value << (32 - rotations)) | (value >> rotations)







class      __lowerCAmelCase     (		unittest.TestCase      ):
					"""simple docstring"""






					def     _a							(     self					:       str					):






								"""simple docstring"""


								import hashlib

								A__       =    bytes('Test String'				,					'utf-8'					)
								self.assertEqual(SHAaaa(_snake_case					).hash				,					hashlib.shaaaa(_snake_case					).hexdigest()					)







def A						(       )						->      None:
			import doctest

			doctest.testmod()

			A__       =    argparse.ArgumentParser()
			parser.add_argument(
			    '-s' ,	'--string' ,	dest='input_string' ,	default='Hello World!! Welcome to Cryptography' ,	help='Hash the string' ,	)
			parser.add_argument(
			    '-f' ,	'--file' ,	dest='input_file' ,	help='Hash contents of a file'					)

			A__       =    parser.parse_args()

			A__       =    args.input_string

			# hash input should be a bytestring
			if args.input_file:
						with open(args.input_file ,	'rb'					) as f:
									A__       =    f.read()
			else:
						A__       =    bytes(__UpperCamelCase ,	'utf-8'					)

			print(SHAaaa(__UpperCamelCase					).hash					)


if __name__ == "__main__":
							main()




