def 			__UpperCamelCase     (    A				):
     UpperCamelCase__					    =   []
     if len(snake_case_				) == 1:
          return [nums.copy()]
     for _ in range(len(snake_case_				)				):
          UpperCamelCase__					    =   nums.pop(0				)
          UpperCamelCase__					    =   permute(snake_case_				)
          for perm in permutations:
               perm.append(snake_case_				)
          result.extend(snake_case_				)
          nums.append(snake_case_				)
     return result







def 			__UpperCamelCase     (    A				):







     def backtrack(A				):
          if start == len(snake_case_				) - 1:
               output.append(nums[:]				)
          else:
               for i in range(snake_case_			,				len(snake_case_				)				):
                    UpperCamelCase__					    =   nums[i], nums[start]
                    backtrack(start + 1				)
                    UpperCamelCase__					    =   nums[i], nums[start]  # backtrack

     UpperCamelCase__					    =   []
     backtrack(0				)
     return output


if __name__ == "__main__":
     import doctest

     # use res to print the data in permute2 function
     __magic_name__    		=permutea([1, 2, 3])
     print(res)
     doctest.testmod()










"""simple docstring"""



import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
       from transformers import AutoModelForSeqaSeqLM, AutoTokenizer






@require_torch
@require_sentencepiece
@require_tokenizers
class 						__snake_case   (						unittest.TestCase	):





 """simple docstring"""


 @slow
 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Any							=	AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small'''   ,		return_dict=__lowerCamelCase    ).to(__lowerCamelCase    )
     __A       :		Optional[Any]							=	AutoTokenizer.from_pretrained('''google/mt5-small'''    )

     __A       :		Optional[int]							=	tokenizer('''Hello there'''   ,		return_tensors='''pt'''    ).input_ids
     __A       :		str							=	tokenizer('''Hi I am'''   ,		return_tensors='''pt'''    ).input_ids

     __A       :		Any							=	model(input_ids.to(__lowerCamelCase    )   ,		labels=labels.to(__lowerCamelCase    )    ).loss
     __A       :		Tuple							=	-(labels.shape[-1] * loss.item())

     __A       :		int							=	-8_4.9_1_2_7
     self.assertTrue(abs(mtf_score - EXPECTED_SCORE    ) < 1e-4    )




