


'''simple docstring'''
import unittest

import numpy as np

from transformers.testing_utils import require_flax, require_tf, require_torch
from transformers.utils import (
    expand_dims,
    flatten_dict,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    reshape,
    squeeze,
    transpose,
)


if is_flax_available():
		import jax.numpy as jnp

if is_tf_available():
		import tensorflow as tf

if is_torch_available():
		import torch
class        lowercase     (							unittest.TestCase ):

		"""simple docstring"""

		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :str							 =			{
							    'task_specific_params': {
							        'summarization': {'length_penalty': 1.0, 'max_length': 128, 'min_length': 12, 'num_beams': 4},
							        'summarization_cnn': {'length_penalty': 2.0, 'max_length': 142, 'min_length': 56, 'num_beams': 4},
							        'summarization_xsum': {'length_penalty': 1.0, 'max_length': 62, 'min_length': 11, 'num_beams': 6},
							    }
							}
							UpperCamelCase__       :Optional[Any]							 =			{
							    'task_specific_params.summarization.length_penalty': 1.0,
							    'task_specific_params.summarization.max_length': 128,
							    'task_specific_params.summarization.min_length': 12,
							    'task_specific_params.summarization.num_beams': 4,
							    'task_specific_params.summarization_cnn.length_penalty': 2.0,
							    'task_specific_params.summarization_cnn.max_length': 142,
							    'task_specific_params.summarization_cnn.min_length': 56,
							    'task_specific_params.summarization_cnn.num_beams': 4,
							    'task_specific_params.summarization_xsum.length_penalty': 1.0,
							    'task_specific_params.summarization_xsum.max_length': 62,
							    'task_specific_params.summarization_xsum.min_length': 11,
							    'task_specific_params.summarization_xsum.num_beams': 6,
							}

							self.assertEqual(flatten_dict(UpperCamelCase_							)   ,       UpperCamelCase_							)




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Dict							 =			np.random.randn(3   ,       4							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_							)   ,       x.transpose()							)							)

							UpperCamelCase__       :Union[str, Any]							 =			np.random.randn(3   ,       4   ,       5							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							)   ,       x.transpose((1, 2, 0)							)							)							)




		@require_torch
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Optional[int]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :Optional[int]							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_							)   ,       transpose(UpperCamelCase_							).numpy()							)							)

							UpperCamelCase__       :List[str]							 =			np.random.randn(3   ,       4   ,       5							)
							UpperCamelCase__       :Dict							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							)   ,       transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							).numpy()							)							)




		@require_tf
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Union[str, Any]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :Dict							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_							)   ,       transpose(UpperCamelCase_							).numpy()							)							)

							UpperCamelCase__       :Union[str, Any]							 =			np.random.randn(3   ,       4   ,       5							)
							UpperCamelCase__       :Dict							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							)   ,       transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							).numpy()							)							)




		@require_flax
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :List[str]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :int							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_							)   ,       np.asarray(transpose(UpperCamelCase_							)							)							)							)

							UpperCamelCase__       :Any							 =			np.random.randn(3   ,       4   ,       5							)
							UpperCamelCase__       :List[Any]							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							)   ,       np.asarray(transpose(UpperCamelCase_   ,       axes=(1, 2, 0)							)							)							)							)




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Optional[int]							 =			np.random.randn(3   ,       4							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (4, 3)							)   ,       np.reshape(UpperCamelCase_   ,       (4, 3)							)							)							)

							UpperCamelCase__       :Dict							 =			np.random.randn(3   ,       4   ,       5							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (12, 5)							)   ,       np.reshape(UpperCamelCase_   ,       (12, 5)							)							)							)




		@require_torch
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :List[str]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :int							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (4, 3)							)   ,       reshape(UpperCamelCase_   ,       (4, 3)							).numpy()							)							)

							UpperCamelCase__       :Tuple							 =			np.random.randn(3   ,       4   ,       5							)
							UpperCamelCase__       :int							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (12, 5)							)   ,       reshape(UpperCamelCase_   ,       (12, 5)							).numpy()							)							)




		@require_tf
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Dict							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :str							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (4, 3)							)   ,       reshape(UpperCamelCase_   ,       (4, 3)							).numpy()							)							)

							UpperCamelCase__       :str							 =			np.random.randn(3   ,       4   ,       5							)
							UpperCamelCase__       :List[str]							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (12, 5)							)   ,       reshape(UpperCamelCase_   ,       (12, 5)							).numpy()							)							)




		@require_flax
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Optional[int]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :Dict							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (4, 3)							)   ,       np.asarray(reshape(UpperCamelCase_   ,       (4, 3)							)							)							)							)

							UpperCamelCase__       :Optional[int]							 =			np.random.randn(3   ,       4   ,       5							)
							UpperCamelCase__       :Optional[int]							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(reshape(UpperCamelCase_   ,       (12, 5)							)   ,       np.asarray(reshape(UpperCamelCase_   ,       (12, 5)							)							)							)							)




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Tuple							 =			np.random.randn(1   ,       3   ,       4							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_							)   ,       np.squeeze(UpperCamelCase_							)							)							)

							UpperCamelCase__       :int							 =			np.random.randn(1   ,       4   ,       1   ,       5							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_   ,       axis=2							)   ,       np.squeeze(UpperCamelCase_   ,       axis=2							)							)							)




		@require_torch
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Tuple							 =			np.random.randn(1   ,       3   ,       4							)
							UpperCamelCase__       :str							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_							)   ,       squeeze(UpperCamelCase_							).numpy()							)							)

							UpperCamelCase__       :Optional[int]							 =			np.random.randn(1   ,       4   ,       1   ,       5							)
							UpperCamelCase__       :Tuple							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_   ,       axis=2							)   ,       squeeze(UpperCamelCase_   ,       axis=2							).numpy()							)							)




		@require_tf
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Optional[Any]							 =			np.random.randn(1   ,       3   ,       4							)
							UpperCamelCase__       :Optional[int]							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_							)   ,       squeeze(UpperCamelCase_							).numpy()							)							)

							UpperCamelCase__       :Union[str, Any]							 =			np.random.randn(1   ,       4   ,       1   ,       5							)
							UpperCamelCase__       :Optional[Any]							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_   ,       axis=2							)   ,       squeeze(UpperCamelCase_   ,       axis=2							).numpy()							)							)




		@require_flax
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :Tuple							 =			np.random.randn(1   ,       3   ,       4							)
							UpperCamelCase__       :int							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_							)   ,       np.asarray(squeeze(UpperCamelCase_							)							)							)							)

							UpperCamelCase__       :Optional[int]							 =			np.random.randn(1   ,       4   ,       1   ,       5							)
							UpperCamelCase__       :Optional[Any]							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(squeeze(UpperCamelCase_   ,       axis=2							)   ,       np.asarray(squeeze(UpperCamelCase_   ,       axis=2							)							)							)							)




		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :int							 =			np.random.randn(3   ,       4							)
							self.assertTrue(np.allclose(expand_dims(UpperCamelCase_   ,       axis=1							)   ,       np.expand_dims(UpperCamelCase_   ,       axis=1							)							)							)




		@require_torch
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :List[str]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :Optional[Any]							 =			torch.tensor(UpperCamelCase_							)
							self.assertTrue(np.allclose(expand_dims(UpperCamelCase_   ,       axis=1							)   ,       expand_dims(UpperCamelCase_   ,       axis=1							).numpy()							)							)




		@require_tf
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :List[Any]							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :Tuple							 =			tf.constant(UpperCamelCase_							)
							self.assertTrue(np.allclose(expand_dims(UpperCamelCase_   ,       axis=1							)   ,       expand_dims(UpperCamelCase_   ,       axis=1							).numpy()							)							)




		@require_flax
		def    lowerCAmelCase__    (		self							):

							'''simple docstring'''


							UpperCamelCase__       :str							 =			np.random.randn(3   ,       4							)
							UpperCamelCase__       :Optional[Any]							 =			jnp.array(UpperCamelCase_							)
							self.assertTrue(np.allclose(expand_dims(UpperCamelCase_   ,       axis=1							)   ,       np.asarray(expand_dims(UpperCamelCase_   ,       axis=1							)							)							)							)










'''simple docstring'''
from __future__ import annotations

from typing import Any


def       a				(      __a       )  ->     None:



					'''simple docstring'''






					create_state_space_tree(__a			, []			, 0       )


def       a				(      __a			, __a			, __a       )  ->     None:



					'''simple docstring'''






					if index == len(__a       ):
										print(__a       )
										return

					create_state_space_tree(__a			, __a			, index + 1       )
					current_subsequence.append(sequence[index]       )
					create_state_space_tree(__a			, __a			, index + 1       )
					current_subsequence.pop()


if __name__ == "__main__":
		__snake_case											=					[3, 1, 2, 4]
		generate_all_subsequences(seq)

		seq.clear()
		seq.extend(['''A''', '''B''', '''C'''])
		generate_all_subsequences(seq)