"""simple docstring"""
import random
import unittest

import numpy as np

import transformers
from transformers import is_flax_available, is_torch_available
from transformers.testing_utils import is_pt_flax_cross_test, require_flax


if is_flax_available():
  import os

  import jax.numpy as jnp
  from jax import jit

  from transformers import AutoTokenizer, FlaxAutoModelForCausalLM
  from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model

  SCREAMING_SNAKE_CASE__   :      str							='0.12'  # assumed parallelism: 8


if is_torch_available():
  import torch



def 					UpperCamelCase					(       SCREAMING_SNAKE_CASE_						,	SCREAMING_SNAKE_CASE_						,	SCREAMING_SNAKE_CASE_=None )      ->Dict:
    if rng is None:
        _lowerCamelCase	: Any       =       random.Random()

    _lowerCamelCase	: Optional[int]       =       1
    for dim in shape:
        total_dims *= dim

    _lowerCamelCase	: List[Any]       =       []
    for _ in range(SCREAMING_SNAKE_CASE_ ):
        values.append(rng.randint(0						,	vocab_size - 1 ) )

    _lowerCamelCase	: Dict       =       np.array(SCREAMING_SNAKE_CASE_						,	dtype=jnp.intaa ).reshape(SCREAMING_SNAKE_CASE_ )

    return output



def 					UpperCamelCase					(       SCREAMING_SNAKE_CASE_						,	SCREAMING_SNAKE_CASE_=None )      ->Tuple:
    _lowerCamelCase	: Optional[int]       =       ids_tensor(SCREAMING_SNAKE_CASE_						,	vocab_size=2						,	rng=SCREAMING_SNAKE_CASE_ )
    # make sure that at least one token is attended to for each batch
    _lowerCamelCase	: Dict       =       1
    return attn_mask



@require_flax
class      _UpperCAmelCase						:






    """simple docstring"""
    __snake_case    =       None
    __snake_case    =       ()







    def 				a__					(			self					)	->	Optional[int]:
        _lowerCamelCase,					_lowerCamelCase	: Optional[Any]       =       self.model_tester.prepare_config_and_inputs_for_common()

        # cut to half length & take max batch_size 3
        _lowerCamelCase	: str       =       2
        _lowerCamelCase	: Tuple       =       inputs['''input_ids'''].shape[-1] // 2
        _lowerCamelCase	: Optional[int]       =       inputs['''input_ids'''][:max_batch_size, :sequence_length]

        _lowerCamelCase	: str       =       jnp.ones_like(__lowerCAmelCase					)
        _lowerCamelCase	: str       =       attention_mask[:max_batch_size, :sequence_length]

        # generate max 5 tokens
        _lowerCamelCase	: Dict       =       input_ids.shape[-1] + 5
        if config.eos_token_id is not None and config.pad_token_id is None:
            # hack to allow generate for models such as GPT2 as is done in `generate()`
            _lowerCamelCase	: Tuple       =       config.eos_token_id
        return config, input_ids, attention_mask, max_length







    @is_pt_flax_cross_test
    def 				a__					(			self					)	->	List[str]:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Tuple       =       self._get_input_ids_and_config()
        _lowerCamelCase	: str       =       False
        _lowerCamelCase	: List[Any]       =       max_length
        _lowerCamelCase	: Dict       =       0

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: List[Any]       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Tuple       =       model_class.__name__[4:]  # Skip the "Flax" at the beginning
            _lowerCamelCase	: Optional[Any]       =       getattr(__lowerCAmelCase    , __lowerCAmelCase					)
            _lowerCamelCase	: List[Any]       =       pt_model_class(__lowerCAmelCase					).eval()
            _lowerCamelCase	: str       =       load_flax_weights_in_pytorch_model(__lowerCAmelCase    , flax_model.params					)

            _lowerCamelCase	: Optional[Any]       =       flax_model.generate(__lowerCAmelCase					).sequences
            _lowerCamelCase	: Optional[int]       =       pt_model.generate(torch.tensor(__lowerCAmelCase    , dtype=torch.long					)					)

            if flax_generation_outputs.shape[-1] > pt_generation_outputs.shape[-1]:
                _lowerCamelCase	: List[str]       =       flax_generation_outputs[:, : pt_generation_outputs.shape[-1]]

            self.assertListEqual(pt_generation_outputs.numpy().tolist()    , flax_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	List[Any]:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Dict       =       self._get_input_ids_and_config()
        _lowerCamelCase	: int       =       False
        _lowerCamelCase	: Optional[int]       =       max_length

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: str       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Dict       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: Union[str, Any]       =       jit(model.generate					)
            _lowerCamelCase	: Dict       =       jit_generate(__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	int:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Dict       =       self._get_input_ids_and_config()
        _lowerCamelCase	: Tuple       =       True
        _lowerCamelCase	: Optional[int]       =       max_length

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Any       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: List[str]       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: List[str]       =       jit(model.generate					)
            _lowerCamelCase	: Optional[Any]       =       jit_generate(__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	Any:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Any       =       self._get_input_ids_and_config()
        _lowerCamelCase	: List[str]       =       False
        _lowerCamelCase	: Any       =       max_length
        _lowerCamelCase	: Any       =       2

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Dict       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Optional[int]       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: Union[str, Any]       =       jit(model.generate					)
            _lowerCamelCase	: List[Any]       =       jit_generate(__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	Optional[int]:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Tuple       =       self._get_input_ids_and_config()
        _lowerCamelCase	: str       =       False
        _lowerCamelCase	: Optional[Any]       =       max_length
        _lowerCamelCase	: Any       =       2
        _lowerCamelCase	: Optional[int]       =       2

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Union[str, Any]       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Optional[Any]       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[0]    , input_ids.shape[0] * config.num_return_sequences					)







    def 				a__					(			self					)	->	Any:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: List[str]       =       self._get_input_ids_and_config()
        _lowerCamelCase	: List[str]       =       True
        _lowerCamelCase	: List[Any]       =       max_length
        _lowerCamelCase	: str       =       0.8
        _lowerCamelCase	: Optional[int]       =       10
        _lowerCamelCase	: Any       =       0.3
        _lowerCamelCase	: Any       =       1
        _lowerCamelCase	: Union[str, Any]       =       8
        _lowerCamelCase	: List[Any]       =       9

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Dict       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Optional[Any]       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: List[Any]       =       jit(model.generate					)
            _lowerCamelCase	: Union[str, Any]       =       jit_generate(__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	int:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Optional[Any]       =       self._get_input_ids_and_config()
        _lowerCamelCase	: Tuple       =       max_length
        _lowerCamelCase	: List[str]       =       1
        _lowerCamelCase	: str       =       8
        _lowerCamelCase	: Optional[Any]       =       9

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: List[Any]       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: List[Any]       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: Optional[int]       =       jit(model.generate					)
            _lowerCamelCase	: str       =       jit_generate(__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	str:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: int       =       self._get_input_ids_and_config()
        _lowerCamelCase	: str       =       max_length
        _lowerCamelCase	: Tuple       =       2
        _lowerCamelCase	: Union[str, Any]       =       1
        _lowerCamelCase	: Tuple       =       8
        _lowerCamelCase	: str       =       9

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: str       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: List[Any]       =       model.generate(__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: Optional[Any]       =       jit(model.generate					)
            _lowerCamelCase	: Optional[Any]       =       jit_generate(__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	int:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: List[str]       =       self._get_input_ids_and_config()

        # pad attention mask on the left
        _lowerCamelCase	: Optional[int]       =       attention_mask.at[(0, 0)].set(0					)

        _lowerCamelCase	: Any       =       False
        _lowerCamelCase	: Optional[int]       =       max_length

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Dict       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Dict       =       model.generate(__lowerCAmelCase    , attention_mask=__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: List[Any]       =       jit(model.generate					)
            _lowerCamelCase	: Tuple       =       jit_generate(__lowerCAmelCase    , attention_mask=__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	int:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: Any       =       self._get_input_ids_and_config()

        # pad attention mask on the left
        _lowerCamelCase	: Dict       =       attention_mask.at[(0, 0)].set(0					)

        _lowerCamelCase	: Optional[int]       =       True
        _lowerCamelCase	: Tuple       =       max_length

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Tuple       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: Tuple       =       model.generate(__lowerCAmelCase    , attention_mask=__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: Tuple       =       jit(model.generate					)
            _lowerCamelCase	: Dict       =       jit_generate(__lowerCAmelCase    , attention_mask=__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)







    def 				a__					(			self					)	->	List[str]:
        _lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase,					_lowerCamelCase	: List[str]       =       self._get_input_ids_and_config()

        # pad attention mask on the left
        _lowerCamelCase	: Optional[Any]       =       attention_mask.at[(0, 0)].set(0					)

        _lowerCamelCase	: Dict       =       2
        _lowerCamelCase	: List[Any]       =       max_length

        for model_class in self.all_generative_model_classes:
            _lowerCamelCase	: Any       =       model_class(__lowerCAmelCase					)

            _lowerCamelCase	: str       =       model.generate(__lowerCAmelCase    , attention_mask=__lowerCAmelCase					).sequences
            self.assertEqual(generation_outputs.shape[-1]    , __lowerCAmelCase					)

            _lowerCamelCase	: List[str]       =       jit(model.generate					)
            _lowerCamelCase	: Optional[Any]       =       jit_generate(__lowerCAmelCase    , attention_mask=__lowerCAmelCase					).sequences

            self.assertListEqual(generation_outputs.tolist()    , jit_generation_outputs.tolist()					)





@require_flax
class      _UpperCAmelCase						( unittest.TestCase						):






    """simple docstring"""







    def 				a__					(			self					)	->	Optional[int]:
        _lowerCamelCase	: Tuple       =       AutoTokenizer.from_pretrained('''hf-internal-testing/tiny-bert'''					)
        _lowerCamelCase	: List[Any]       =       FlaxAutoModelForCausalLM.from_pretrained('''hf-internal-testing/tiny-bert-flax-only'''					)

        _lowerCamelCase	: int       =       '''Hello world'''
        _lowerCamelCase	: Union[str, Any]       =       tokenizer(__lowerCAmelCase    , return_tensors='''np'''					).input_ids

        # typos are quickly detected (the correct argument is `do_sample`)
        with self.assertRaisesRegex(__lowerCAmelCase    , '''do_samples'''					):
            model.generate(__lowerCAmelCase    , do_samples=__lowerCAmelCase					)

        # arbitrary arguments that will not be used anywhere are also not accepted
        with self.assertRaisesRegex(__lowerCAmelCase    , '''foo'''					):
            _lowerCamelCase	: List[str]       =       {'''foo''': '''bar'''}
            model.generate(__lowerCAmelCase    , **__lowerCAmelCase					)








'''simple docstring'''


def 						lowerCamelCase__   (				a							):
						if not all(x.isalpha() for x in string							):
												raise ValueError('String must only contain alphabetic characters.'							)

						__snake_case						 =   sorted(string.lower()							)
						return len(a							) == len(set(a							)							)


if __name__ == "__main__":
	_lowercase  =			input("""Enter a string """).strip()

	_lowercase  =			is_isogram(input_str)
	print(f'''{input_str} is {'an' if isogram else 'not an'} isogram.''')

