



"""simple docstring"""





import json
import os
import unittest

from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast
from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin




@require_tokenizers
class 			lowercase__			(      A,					unittest.TestCase    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					GPTaTokenizer
							_UpperCAmelCase      				=					GPTaTokenizerFast
							_UpperCAmelCase      				=					True
							_UpperCAmelCase      				=					{'''add_prefix_space''': True}
							_UpperCAmelCase      				=					False






							def        lowerCamelCase_   (  self						)			->							Any:
									super().setUp()

									# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
									_UpperCAmelCase							 =		[
									    'l',
									    'o',
									    'w',
									    'e',
									    'r',
									    's',
									    't',
									    'i',
									    'd',
									    'n',
									    '\u0120',
									    '\u0120l',
									    '\u0120n',
									    '\u0120lo',
									    '\u0120low',
									    'er',
									    '\u0120lowest',
									    '\u0120newer',
									    '\u0120wider',
									    '<unk>',
									    '<|endoftext|>',
									]
									_UpperCAmelCase							 =		dict(zip(snake_case	,       range(len(snake_case						)						)						)						)
									_UpperCAmelCase							 =		['#version: 0.2', '\u0120 l', '\u0120l o', '\u0120lo w', 'e r', '']
									_UpperCAmelCase							 =		{'unk_token': '<unk>'}

									_UpperCAmelCase							 =		os.path.join(self.tmpdirname	,       VOCAB_FILES_NAMES['vocab_file']						)
									_UpperCAmelCase							 =		os.path.join(self.tmpdirname	,       VOCAB_FILES_NAMES['merges_file']						)
									with open(self.vocab_file	,       'w'	,       encoding='utf-8'						) as fp:
											fp.write(json.dumps(snake_case						) + '\n'						)
									with open(self.merges_file	,       'w'	,       encoding='utf-8'						) as fp:
											fp.write('\n'.join(snake_case						)						)






							def        lowerCamelCase_   (  self	,       **snake_case						)			->							Dict:
									kwargs.update(self.special_tokens_map						)
									return GPTaTokenizer.from_pretrained(self.tmpdirname	,       **snake_case						)






							def        lowerCamelCase_   (  self	,       **snake_case						)			->							Union[str, Any]:
									kwargs.update(self.special_tokens_map						)
									return GPTaTokenizerFast.from_pretrained(self.tmpdirname	,       **snake_case						)






							def        lowerCamelCase_   (  self	,       snake_case						)			->							Optional[Any]:
									_UpperCAmelCase							 =		'lower newer'
									_UpperCAmelCase							 =		'lower newer'
									return input_text, output_text






							def        lowerCamelCase_   (  self						)			->							Tuple:
									_UpperCAmelCase							 =		GPTaTokenizer(self.vocab_file	,       self.merges_file	,       **self.special_tokens_map						)
									_UpperCAmelCase							 =		'lower newer'
									_UpperCAmelCase							 =		['\u0120low', 'er', '\u0120', 'n', 'e', 'w', 'er']
									_UpperCAmelCase							 =		tokenizer.tokenize(snake_case	,       add_prefix_space=snake_case						)
									self.assertListEqual(snake_case	,       snake_case						)

									_UpperCAmelCase							 =		tokens + [tokenizer.unk_token]
									_UpperCAmelCase							 =		[14, 15, 10, 9, 3, 2, 15, 19]
									self.assertListEqual(tokenizer.convert_tokens_to_ids(snake_case						)	,       snake_case						)






							def        lowerCamelCase_   (  self						)			->							int:
									if not self.test_rust_tokenizer:
											return

									_UpperCAmelCase							 =		self.get_tokenizer()
									_UpperCAmelCase							 =		self.get_rust_tokenizer(add_prefix_space=snake_case						)

									_UpperCAmelCase							 =		'lower newer'

									# Testing tokenization
									_UpperCAmelCase							 =		tokenizer.tokenize(snake_case	,       add_prefix_space=snake_case						)
									_UpperCAmelCase							 =		rust_tokenizer.tokenize(snake_case						)
									self.assertListEqual(snake_case	,       snake_case						)

									# Testing conversion to ids without special tokens
									_UpperCAmelCase							 =		tokenizer.encode(snake_case	,       add_special_tokens=snake_case	,       add_prefix_space=snake_case						)
									_UpperCAmelCase							 =		rust_tokenizer.encode(snake_case	,       add_special_tokens=snake_case						)
									self.assertListEqual(snake_case	,       snake_case						)

									# Testing conversion to ids with special tokens
									_UpperCAmelCase							 =		self.get_rust_tokenizer(add_prefix_space=snake_case						)
									_UpperCAmelCase							 =		tokenizer.encode(snake_case	,       add_prefix_space=snake_case						)
									_UpperCAmelCase							 =		rust_tokenizer.encode(snake_case						)
									self.assertListEqual(snake_case	,       snake_case						)

									# Testing the unknown token
									_UpperCAmelCase							 =		tokens + [rust_tokenizer.unk_token]
									_UpperCAmelCase							 =		[14, 15, 10, 9, 3, 2, 15, 19]
									self.assertListEqual(rust_tokenizer.convert_tokens_to_ids(snake_case						)	,       snake_case						)






							def        lowerCamelCase_   (  self	,       *snake_case	,       **snake_case						)			->							List[str]:
									# It's very difficult to mix/test pretokenization with byte-level
									# And get both GPT2 and Roberta to work at the same time (mostly an issue of adding a space before the string)
									pass






							def        lowerCamelCase_   (  self	,       snake_case=15						)			->							List[Any]:
									for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
											with self.subTest(f'{tokenizer.__class__.__name__} ({pretrained_name})'						):
													_UpperCAmelCase							 =		self.rust_tokenizer_class.from_pretrained(snake_case	,       **snake_case						)

													# Simple input
													_UpperCAmelCase							 =		'This is a simple input'
													_UpperCAmelCase							 =		['This is a simple input 1', 'This is a simple input 2']
													_UpperCAmelCase							 =		('This is a simple input', 'This is a pair')
													_UpperCAmelCase							 =		[
													    ('This is a simple input 1', 'This is a simple input 2'),
													    ('This is a simple pair 1', 'This is a simple pair 2'),
													]

													# Simple input tests
													self.assertRaises(snake_case	,       tokenizer_r.encode	,       snake_case	,       max_length=snake_case	,       padding='max_length'						)

													# Simple input
													self.assertRaises(snake_case	,       tokenizer_r.encode_plus	,       snake_case	,       max_length=snake_case	,       padding='max_length'						)

													# Simple input
													self.assertRaises(
													    snake_case	,       tokenizer_r.batch_encode_plus	,       snake_case	,       max_length=snake_case	,       padding='max_length'	,       )

													# Pair input
													self.assertRaises(snake_case	,       tokenizer_r.encode	,       snake_case	,       max_length=snake_case	,       padding='max_length'						)

													# Pair input
													self.assertRaises(snake_case	,       tokenizer_r.encode_plus	,       snake_case	,       max_length=snake_case	,       padding='max_length'						)

													# Pair input
													self.assertRaises(
													    snake_case	,       tokenizer_r.batch_encode_plus	,       snake_case	,       max_length=snake_case	,       padding='max_length'	,       )






							def        lowerCamelCase_   (  self						)			->							int:
									_UpperCAmelCase							 =		GPTaTokenizer.from_pretrained(self.tmpdirname	,       pad_token='<pad>'						)

									# Simple input
									_UpperCAmelCase							 =		'This is a simple input'
									_UpperCAmelCase							 =		['This is a simple input looooooooong', 'This is a simple input']
									_UpperCAmelCase							 =		('This is a simple input', 'This is a pair')
									_UpperCAmelCase							 =		[
									    ('This is a simple input loooooong', 'This is a simple input'),
									    ('This is a simple pair loooooong', 'This is a simple pair'),
									]

									_UpperCAmelCase							 =		tokenizer.pad_token_id

									_UpperCAmelCase							 =		tokenizer(snake_case	,       padding='max_length'	,       max_length=30	,       return_tensors='np'						)
									_UpperCAmelCase							 =		tokenizer(snake_case	,       padding=snake_case	,       truncate=snake_case	,       return_tensors='np'						)
									_UpperCAmelCase							 =		tokenizer(*snake_case	,       padding='max_length'	,       max_length=60	,       return_tensors='np'						)
									_UpperCAmelCase							 =		tokenizer(snake_case	,       padding=snake_case	,       truncate=snake_case	,       return_tensors='np'						)

									# s
									# test single string max_length padding
									self.assertEqual(out_s['input_ids'].shape[-1]	,       30						)
									self.assertTrue(pad_token_id in out_s['input_ids']						)
									self.assertTrue(0 in out_s['attention_mask']						)

									# s2
									# test automatic padding
									self.assertEqual(out_sa['input_ids'].shape[-1]	,       33						)
									# long slice doesn't have padding
									self.assertFalse(pad_token_id in out_sa['input_ids'][0]						)
									self.assertFalse(0 in out_sa['attention_mask'][0]						)
									# short slice does have padding
									self.assertTrue(pad_token_id in out_sa['input_ids'][1]						)
									self.assertTrue(0 in out_sa['attention_mask'][1]						)

									# p
									# test single pair max_length padding
									self.assertEqual(out_p['input_ids'].shape[-1]	,       60						)
									self.assertTrue(pad_token_id in out_p['input_ids']						)
									self.assertTrue(0 in out_p['attention_mask']						)

									# p2
									# test automatic padding pair
									self.assertEqual(out_pa['input_ids'].shape[-1]	,       52						)
									# long slice pair doesn't have padding
									self.assertFalse(pad_token_id in out_pa['input_ids'][0]						)
									self.assertFalse(0 in out_pa['attention_mask'][0]						)
									# short slice pair does have padding
									self.assertTrue(pad_token_id in out_pa['input_ids'][1]						)
									self.assertTrue(0 in out_pa['attention_mask'][1]						)






							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		'$$$'
									_UpperCAmelCase							 =		GPTaTokenizer.from_pretrained(self.tmpdirname	,       bos_token=snake_case	,       add_bos_token=snake_case						)

									_UpperCAmelCase							 =		'This is a simple input'
									_UpperCAmelCase							 =		['This is a simple input 1', 'This is a simple input 2']

									_UpperCAmelCase							 =		tokenizer.bos_token_id

									_UpperCAmelCase							 =		tokenizer(snake_case						)
									_UpperCAmelCase							 =		tokenizer(snake_case						)

									self.assertEqual(out_s.input_ids[0]	,       snake_case						)
									self.assertTrue(all(o[0] == bos_token_id for o in out_sa.input_ids						)						)

									_UpperCAmelCase							 =		tokenizer.decode(out_s.input_ids						)
									_UpperCAmelCase							 =		tokenizer.batch_decode(out_sa.input_ids						)

									self.assertEqual(decode_s.split()[0]	,       snake_case						)
									self.assertTrue(all(d.split()[0] == bos_token for d in decode_sa						)						)






							def        lowerCamelCase_   (  self						)			->							Dict:
									pass






							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									# TODO: change to self.get_tokenizers() when the fast version is implemented
									_UpperCAmelCase							 =		[self.get_tokenizer(do_lower_case=snake_case	,       add_bos_token=snake_case						)]
									for tokenizer in tokenizers:
											with self.subTest(f'{tokenizer.__class__.__name__}'						):
													_UpperCAmelCase							 =		'Encode this.'
													_UpperCAmelCase							 =		'This one too please.'
													_UpperCAmelCase							 =		tokenizer.encode(snake_case	,       add_special_tokens=snake_case						)
													encoded_sequence += tokenizer.encode(snake_case	,       add_special_tokens=snake_case						)
													_UpperCAmelCase							 =		tokenizer.encode_plus(
													    snake_case	,       snake_case	,       add_special_tokens=snake_case	,       return_special_tokens_mask=snake_case	,       )
													_UpperCAmelCase							 =		encoded_sequence_dict['input_ids']
													_UpperCAmelCase							 =		encoded_sequence_dict['special_tokens_mask']
													self.assertEqual(len(snake_case						)	,       len(snake_case						)						)

													_UpperCAmelCase							 =		[
													    (x if not special_tokens_mask[i] else None) for i, x in enumerate(snake_case						)
													]
													_UpperCAmelCase							 =		[x for x in filtered_sequence if x is not None]
													self.assertEqual(snake_case	,       snake_case						)







@require_tokenizers
class 			lowercase__			(      unittest.TestCase    ):
							'''simple docstring'''







							def        lowerCamelCase_   (  self						)			->							str:
									# More context:
									# https://huggingface.co/wjmcat/opt-350m-paddle/discussions/1
									# https://huggingface.slack.com/archives/C01N44FJDHT/p1653511495183519
									# https://github.com/huggingface/transformers/pull/17088#discussion_r871246439

									_UpperCAmelCase							 =		AutoTokenizer.from_pretrained('facebook/opt-350m'	,       from_slow=snake_case						)
									_UpperCAmelCase							 =		'A photo of a cat'

									_UpperCAmelCase							 =		tokenizer.encode(
									    snake_case	,       )
									self.assertEqual(snake_case	,       [2, 250, 1345, 9, 10, 4758]						)
									tokenizer.save_pretrained('test_opt'						)

									_UpperCAmelCase							 =		AutoTokenizer.from_pretrained('./test_opt'						)
									_UpperCAmelCase							 =		tokenizer.encode(
									    snake_case	,       )
									self.assertEqual(snake_case	,       [2, 250, 1345, 9, 10, 4758]						)






							def        lowerCamelCase_   (  self						)			->							int:
									_UpperCAmelCase							 =		AutoTokenizer.from_pretrained('facebook/opt-350m'	,       use_slow=snake_case						)
									_UpperCAmelCase							 =		'A photo of a cat'

									_UpperCAmelCase							 =		tokenizer.encode(
									    snake_case	,       )
									# Same as above
									self.assertEqual(snake_case	,       [2, 250, 1345, 9, 10, 4758]						)






							@unittest.skip('This test is failing because of a bug in the fast tokenizer'						)
							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		AutoTokenizer.from_pretrained('facebook/opt-350m'	,       from_slow=snake_case						)

									_UpperCAmelCase							 =		'bos'
									_UpperCAmelCase							 =		tokenizer.get_vocab()['bos']

									_UpperCAmelCase							 =		'A photo of a cat'
									_UpperCAmelCase							 =		tokenizer.encode(
									    snake_case	,       )
									# We changed the bos token
									self.assertEqual(snake_case	,       [31957, 250, 1345, 9, 10, 4758]						)
									tokenizer.save_pretrained('./tok'						)
									_UpperCAmelCase							 =		AutoTokenizer.from_pretrained('./tok'						)
									self.assertTrue(tokenizer.is_fast						)
									_UpperCAmelCase							 =		tokenizer.encode(
									    snake_case	,       )
									self.assertEqual(snake_case	,       [31957, 250, 1345, 9, 10, 4758]						)







"""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						)			->							Dict:
									_UpperCAmelCase							 =		{
									    '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							 =		{
									    '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(snake_case						)	,       snake_case						)






							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       x.transpose()						)						)

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






							@require_torch
							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       transpose(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       transpose(snake_case	,       axes=(1, 2, 0)						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       transpose(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       transpose(snake_case	,       axes=(1, 2, 0)						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case						)	,       np.asarray(transpose(snake_case						)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(transpose(snake_case	,       axes=(1, 2, 0)						)	,       np.asarray(transpose(snake_case	,       axes=(1, 2, 0)						)						)						)						)






							def        lowerCamelCase_   (  self						)			->							List[str]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       np.reshape(snake_case	,       (4, 3)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       np.reshape(snake_case	,       (12, 5)						)						)						)






							@require_torch
							def        lowerCamelCase_   (  self						)			->							Optional[Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       reshape(snake_case	,       (4, 3)						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       reshape(snake_case	,       (12, 5)						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       reshape(snake_case	,       (4, 3)						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       reshape(snake_case	,       (12, 5)						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							Tuple:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (4, 3)						)	,       np.asarray(reshape(snake_case	,       (4, 3)						)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(3	,       4	,       5						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(reshape(snake_case	,       (12, 5)						)	,       np.asarray(reshape(snake_case	,       (12, 5)						)						)						)						)






							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       np.squeeze(snake_case						)						)						)

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






							@require_torch
							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       squeeze(snake_case						).numpy()						)						)

									_UpperCAmelCase							 =		np.random.randn(1	,       4	,       1	,       5						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case	,       axis=2						)	,       squeeze(snake_case	,       axis=2						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							Optional[int]:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       squeeze(snake_case						).numpy()						)						)

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






							@require_flax
							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		np.random.randn(1	,       3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case						)	,       np.asarray(squeeze(snake_case						)						)						)						)

									_UpperCAmelCase							 =		np.random.randn(1	,       4	,       1	,       5						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(squeeze(snake_case	,       axis=2						)	,       np.asarray(squeeze(snake_case	,       axis=2						)						)						)						)






							def        lowerCamelCase_   (  self						)			->							Union[str, Any]:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       np.expand_dims(snake_case	,       axis=1						)						)						)






							@require_torch
							def        lowerCamelCase_   (  self						)			->							Dict:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		torch.tensor(snake_case						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       expand_dims(snake_case	,       axis=1						).numpy()						)						)






							@require_tf
							def        lowerCamelCase_   (  self						)			->							int:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		tf.constant(snake_case						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       expand_dims(snake_case	,       axis=1						).numpy()						)						)






							@require_flax
							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		np.random.randn(3	,       4						)
									_UpperCAmelCase							 =		jnp.array(snake_case						)
									self.assertTrue(np.allclose(expand_dims(snake_case	,       axis=1						)	,       np.asarray(expand_dims(snake_case	,       axis=1						)						)						)						)


