





'''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 			SCREAMING_SNAKE_CASE   (unittest.TestCase							):


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Tuple								=	{
              '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},
              }
          }
          __A						:			List[str]								=	{
              '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 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Union[str, Any]								=	np.random.randn(3						,     4)
          self.assertTrue(np.allclose(transpose(_UpperCAmelCase)						,     x.transpose()))

          __A						:			Tuple								=	np.random.randn(3						,     4						,     5)
          self.assertTrue(np.allclose(transpose(_UpperCAmelCase						,     axes=(1, 2, 0))						,     x.transpose((1, 2, 0))))


     @require_torch
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Dict								=	np.random.randn(3						,     4)
          __A						:			Union[str, Any]								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(transpose(_UpperCAmelCase)						,     transpose(_UpperCAmelCase).numpy()))

          __A						:			Union[str, Any]								=	np.random.randn(3						,     4						,     5)
          __A						:			Dict								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(transpose(_UpperCAmelCase						,     axes=(1, 2, 0))						,     transpose(_UpperCAmelCase						,     axes=(1, 2, 0)).numpy()))


     @require_tf
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Union[str, Any]								=	np.random.randn(3						,     4)
          __A						:			List[Any]								=	tf.constant(_UpperCAmelCase)
          self.assertTrue(np.allclose(transpose(_UpperCAmelCase)						,     transpose(_UpperCAmelCase).numpy()))

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


     @require_flax
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






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

          __A						:			Optional[int]								=	np.random.randn(3						,     4						,     5)
          __A						:			int								=	jnp.array(_UpperCAmelCase)
          self.assertTrue(np.allclose(transpose(_UpperCAmelCase						,     axes=(1, 2, 0))						,     np.asarray(transpose(_UpperCAmelCase						,     axes=(1, 2, 0)))))


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






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

          __A						:			Optional[Any]								=	np.random.randn(3						,     4						,     5)
          self.assertTrue(np.allclose(reshape(_UpperCAmelCase						,     (12, 5))						,     np.reshape(_UpperCAmelCase						,     (12, 5))))


     @require_torch
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			int								=	np.random.randn(3						,     4)
          __A						:			Dict								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(reshape(_UpperCAmelCase						,     (4, 3))						,     reshape(_UpperCAmelCase						,     (4, 3)).numpy()))

          __A						:			List[str]								=	np.random.randn(3						,     4						,     5)
          __A						:			Any								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(reshape(_UpperCAmelCase						,     (12, 5))						,     reshape(_UpperCAmelCase						,     (12, 5)).numpy()))


     @require_tf
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Dict								=	np.random.randn(3						,     4)
          __A						:			List[Any]								=	tf.constant(_UpperCAmelCase)
          self.assertTrue(np.allclose(reshape(_UpperCAmelCase						,     (4, 3))						,     reshape(_UpperCAmelCase						,     (4, 3)).numpy()))

          __A						:			Dict								=	np.random.randn(3						,     4						,     5)
          __A						:			List[Any]								=	tf.constant(_UpperCAmelCase)
          self.assertTrue(np.allclose(reshape(_UpperCAmelCase						,     (12, 5))						,     reshape(_UpperCAmelCase						,     (12, 5)).numpy()))


     @require_flax
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			int								=	np.random.randn(3						,     4)
          __A						:			List[str]								=	jnp.array(_UpperCAmelCase)
          self.assertTrue(np.allclose(reshape(_UpperCAmelCase						,     (4, 3))						,     np.asarray(reshape(_UpperCAmelCase						,     (4, 3)))))

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


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			List[Any]								=	np.random.randn(1						,     3						,     4)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase)						,     np.squeeze(_UpperCAmelCase)))

          __A						:			Any								=	np.random.randn(1						,     4						,     1						,     5)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase						,     axis=2)						,     np.squeeze(_UpperCAmelCase						,     axis=2)))


     @require_torch
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			str								=	np.random.randn(1						,     3						,     4)
          __A						:			Union[str, Any]								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase)						,     squeeze(_UpperCAmelCase).numpy()))

          __A						:			List[Any]								=	np.random.randn(1						,     4						,     1						,     5)
          __A						:			Dict								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase						,     axis=2)						,     squeeze(_UpperCAmelCase						,     axis=2).numpy()))


     @require_tf
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Optional[Any]								=	np.random.randn(1						,     3						,     4)
          __A						:			Union[str, Any]								=	tf.constant(_UpperCAmelCase)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase)						,     squeeze(_UpperCAmelCase).numpy()))

          __A						:			Any								=	np.random.randn(1						,     4						,     1						,     5)
          __A						:			Tuple								=	tf.constant(_UpperCAmelCase)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase						,     axis=2)						,     squeeze(_UpperCAmelCase						,     axis=2).numpy()))


     @require_flax
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Optional[int]								=	np.random.randn(1						,     3						,     4)
          __A						:			List[Any]								=	jnp.array(_UpperCAmelCase)
          self.assertTrue(np.allclose(squeeze(_UpperCAmelCase)						,     np.asarray(squeeze(_UpperCAmelCase))))

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


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Optional[int]								=	np.random.randn(3						,     4)
          self.assertTrue(np.allclose(expand_dims(_UpperCAmelCase						,     axis=1)						,     np.expand_dims(_UpperCAmelCase						,     axis=1)))


     @require_torch
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Union[str, Any]								=	np.random.randn(3						,     4)
          __A						:			Dict								=	torch.tensor(_UpperCAmelCase)
          self.assertTrue(np.allclose(expand_dims(_UpperCAmelCase						,     axis=1)						,     expand_dims(_UpperCAmelCase						,     axis=1).numpy()))


     @require_tf
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Dict								=	np.random.randn(3						,     4)
          __A						:			Tuple								=	tf.constant(_UpperCAmelCase)
          self.assertTrue(np.allclose(expand_dims(_UpperCAmelCase						,     axis=1)						,     expand_dims(_UpperCAmelCase						,     axis=1).numpy()))


     @require_flax
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						:			Optional[int]								=	np.random.randn(3						,     4)
          __A						:			Dict								=	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






def 	_lowerCAmelCase      (  __snake_case  :			list[int | str]      )					->					None:
     create_state_space_tree(__snake_case			,							[]			,							0			,							[0 for i in range(len(__snake_case      )      )]      )






def 	_lowerCAmelCase      (  __snake_case  :			list[int | str]			,							__snake_case  :			list[int | str]			,							__snake_case  :			int			,							__snake_case  :			list[int]			,							)					->					None:

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

     for i in range(len(__snake_case      )      ):
          if not index_used[i]:
               current_sequence.append(sequence[i]      )
               __A						:			Any								=	True
               create_state_space_tree(__snake_case			,							__snake_case			,							index + 1			,							__snake_case      )
               current_sequence.pop()
               __A						:			Any								=	False
lowercase__   :				list[int | str]      =   [3, 1, 2, 4]
generate_all_permutations(sequence)

lowercase__   :				list[int | str]      =   ["A", "B", "C"]







generate_all_permutations(sequence_a)