




import argparse
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_dummies.py
UpperCamelCase__ :   List[str]						=							'''src/diffusers'''

# Matches is_xxx_available()
UpperCamelCase__ :   Optional[int]						=							re.compile(r'''is\_([a-z_]*)_available\(\)''')
# Matches from xxx import bla
UpperCamelCase__ :   Tuple						=							re.compile(r'''\s+from\s+\S*\s+import\s+([^\(\s].*)\n''')


UpperCamelCase__ :   Union[str, Any]						=							'''
{0} = None
'''

UpperCamelCase__ :   Any						=							'''
class {0}(metaclass=DummyObject):
    _backends = {1}

    def __init__(self, *args, **kwargs):
        requires_backends(self, {1})

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, {1})

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, {1})
'''


UpperCamelCase__ :   Dict						=							'''
def {0}(*args, **kwargs):
    requires_backends({0}, {1})
'''





def        __UpperCAmelCase						(							lowerCamelCase_ :     Union[str, Any]  )       ->  int:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Tuple					  =      _re_backend.findall(lowerCamelCase_  )
			if len(lowerCamelCase_  ) == 0:
						return None

			return "_and_".join(lowerCamelCase_  )





def        __UpperCAmelCase						(							)       ->  Optional[int]:







			"""simple docstring"""





			with open(os.path.join(lowerCamelCase_  ,							'__init__.py'  )  ,							'r'  ,							encoding='utf-8'  ,							newline='\n'  ) as f:
						SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      f.readlines()

			# Get to the point we do the actual imports for type checking
			SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      0
			SCREAMING_SNAKE_CASE_   : List[str]					  =      {}
			# Go through the end of the file
			while line_index < len(lowerCamelCase_  ):
						# If the line contains is_backend_available, we grab all objects associated with the `else` block
						SCREAMING_SNAKE_CASE_   : Dict					  =      find_backend(lines[line_index]  )
						if backend is not None:
									while not lines[line_index].startswith('else:'  ):
												line_index += 1
									line_index += 1
									SCREAMING_SNAKE_CASE_   : Tuple					  =      []
									# Until we unindent, add backend objects to the list
									while line_index < len(lowerCamelCase_  ) and len(lines[line_index]  ) > 1:
												SCREAMING_SNAKE_CASE_   : Dict					  =      lines[line_index]
												SCREAMING_SNAKE_CASE_   : int					  =      _re_single_line_import.search(lowerCamelCase_  )
												if single_line_import_search is not None:
															objects.extend(single_line_import_search.groups()[0].split(', '  )  )
												elif line.startswith(' ' * 8  ):
															objects.append(line[8:-2]  )
												line_index += 1

									if len(lowerCamelCase_  ) > 0:
												SCREAMING_SNAKE_CASE_   : List[Any]					  =      objects
						else:
									line_index += 1

			return backend_specific_objects





def        __UpperCAmelCase						(							lowerCamelCase_ :     Optional[int]  ,							lowerCamelCase_ :     List[Any]  )       ->  str:







			"""simple docstring"""





			if name.isupper():
						return DUMMY_CONSTANT.format(lowerCamelCase_  )
			elif name.islower():
						return DUMMY_FUNCTION.format(lowerCamelCase_  ,							lowerCamelCase_  )
			else:
						return DUMMY_CLASS.format(lowerCamelCase_  ,							lowerCamelCase_  )





def        __UpperCAmelCase						(							lowerCamelCase_ :     List[Any]=None  )       ->  str:







			"""simple docstring"""





			if backend_specific_objects is None:
						SCREAMING_SNAKE_CASE_   : Any					  =      read_init()
			# For special correspondence backend to module name as used in the function requires_modulename
			SCREAMING_SNAKE_CASE_   : Optional[int]					  =      {}

			for backend, objects in backend_specific_objects.items():
						SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      '[' + ', '.join(F'"{b}"' for b in backend.split('_and_'  )  ) + ']'
						SCREAMING_SNAKE_CASE_   : Dict					  =      '# This file is autogenerated by the command `make fix-copies`, do not edit.\n'
						dummy_file += "from ..utils import DummyObject, requires_backends\n\n"
						dummy_file += "\n".join([create_dummy_object(lowerCamelCase_  ,							lowerCamelCase_  ) for o in objects]  )
						SCREAMING_SNAKE_CASE_   : Dict					  =      dummy_file

			return dummy_files





def        __UpperCAmelCase						(							lowerCamelCase_ :     Optional[Any]=False  )       ->  Tuple:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      create_dummy_files()
			# For special correspondence backend to shortcut as used in utils/dummy_xxx_objects.py
			SCREAMING_SNAKE_CASE_   : int					  =      {'torch': 'pt'}

			# Locate actual dummy modules and read their content.
			SCREAMING_SNAKE_CASE_   : Optional[int]					  =      os.path.join(lowerCamelCase_  ,							'utils'  )
			SCREAMING_SNAKE_CASE_   : List[Any]					  =      {
			    backend: os.path.join(lowerCamelCase_  ,							F'dummy_{short_names.get(lowerCamelCase_  ,							lowerCamelCase_  )}_objects.py'  )
			    for backend in dummy_files.keys()
			}

			SCREAMING_SNAKE_CASE_   : List[Any]					  =      {}
			for backend, file_path in dummy_file_paths.items():
						if os.path.isfile(lowerCamelCase_  ):
									with open(lowerCamelCase_  ,							'r'  ,							encoding='utf-8'  ,							newline='\n'  ) as f:
												SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      f.read()
						else:
									SCREAMING_SNAKE_CASE_   : List[str]					  =      ''

			for backend in dummy_files.keys():
						if dummy_files[backend] != actual_dummies[backend]:
									if overwrite:
												print(
												    F'Updating diffusers.utils.dummy_{short_names.get(lowerCamelCase_  ,							lowerCamelCase_  )}_objects.py as the main '
												    '__init__ has new objects.'  )
												with open(dummy_file_paths[backend]  ,							'w'  ,							encoding='utf-8'  ,							newline='\n'  ) as f:
															f.write(dummy_files[backend]  )
									else:
												raise ValueError(
												    'The main __init__ has objects that are not present in '
												    F'diffusers.utils.dummy_{short_names.get(lowerCamelCase_  ,							lowerCamelCase_  )}_objects.py. Run `make fix-copies` '
												    'to fix this.'  )


if __name__ == "__main__":
						UpperCamelCase__ :   Tuple						=							argparse.ArgumentParser()
						parser.add_argument('''--fix_and_overwrite''', action='''store_true''', help='''Whether to fix inconsistencies.''')
						UpperCamelCase__ :   Tuple						=							parser.parse_args()

						check_dummies(args.fix_and_overwrite)









import unittest

import numpy as np

from transformers import is_flax_available
from transformers.testing_utils import require_flax

from ..test_modeling_flax_common import ids_tensor


if is_flax_available():
						import jax
						import jax.numpy as jnp

						from transformers.generation import (
						    FlaxForcedBOSTokenLogitsProcessor,
						    FlaxForcedEOSTokenLogitsProcessor,
						    FlaxLogitsProcessorList,
						    FlaxMinLengthLogitsProcessor,
						    FlaxTemperatureLogitsWarper,
						    FlaxTopKLogitsWarper,
						    FlaxTopPLogitsWarper,
						)







@require_flax
class 				lowerCAmelCase_       (					unittest.TestCase							):






				def 		snake_case	(			self      ,snake_case__      ,snake_case__ ):
							SCREAMING_SNAKE_CASE_   : int					  =      jnp.ones((batch_size, length) ) / length
							return scores






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : str					  =      None
							SCREAMING_SNAKE_CASE_   : int					  =      20

							SCREAMING_SNAKE_CASE_   : int					  =      self._get_uniform_logits(batch_size=2      ,length=snake_case__ )

							# tweak scores to not be uniform anymore
							SCREAMING_SNAKE_CASE_   : Any					  =      scores.at[1, 5].set((1 / length) + 0.1 )  # peak, 1st batch
							SCREAMING_SNAKE_CASE_   : Dict					  =      scores.at[1, 10].set((1 / length) - 0.4 )  # valley, 1st batch

							# compute softmax
							SCREAMING_SNAKE_CASE_   : int					  =      jax.nn.softmax(snake_case__      ,axis=-1 )

							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      FlaxTemperatureLogitsWarper(temperature=0.5 )
							SCREAMING_SNAKE_CASE_   : Dict					  =      FlaxTemperatureLogitsWarper(temperature=1.3 )

							SCREAMING_SNAKE_CASE_   : Any					  =      jax.nn.softmax(temp_dist_warper_sharper(snake_case__      ,scores.copy()      ,cur_len=snake_case__ )      ,axis=-1 )
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      jax.nn.softmax(temp_dist_warper_smoother(snake_case__      ,scores.copy()      ,cur_len=snake_case__ )      ,axis=-1 )

							# uniform distribution stays uniform
							self.assertTrue(jnp.allclose(probs[0, :]      ,warped_prob_sharp[0, :]      ,atol=1E-3 ) )
							self.assertTrue(jnp.allclose(probs[0, :]      ,warped_prob_smooth[0, :]      ,atol=1E-3 ) )

							# sharp peaks get higher, valleys get lower
							self.assertLess(probs[1, :].max()      ,warped_prob_sharp[1, :].max() )
							self.assertGreater(probs[1, :].min()      ,warped_prob_sharp[1, :].min() )

							# smooth peaks get lower, valleys get higher
							self.assertGreater(probs[1, :].max()      ,warped_prob_smooth[1, :].max() )
							self.assertLess(probs[1, :].min()      ,warped_prob_smooth[1, :].min() )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : Any					  =      None
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      10
							SCREAMING_SNAKE_CASE_   : int					  =      2

							# create ramp distribution
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      np.broadcast_to(np.arange(snake_case__ )[None, :]      ,(batch_size, vocab_size) ).copy()
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      ramp_logits[1:, : vocab_size // 2] + vocab_size

							SCREAMING_SNAKE_CASE_   : List[str]					  =      FlaxTopKLogitsWarper(3 )

							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      top_k_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )

							# check that correct tokens are filtered
							self.assertListEqual(jnp.isinf(scores[0] ).tolist()      ,7 * [True] + 3 * [False] )
							self.assertListEqual(jnp.isinf(scores[1] ).tolist()      ,2 * [True] + 3 * [False] + 5 * [True] )

							# check special case
							SCREAMING_SNAKE_CASE_   : int					  =      5
							SCREAMING_SNAKE_CASE_   : Any					  =      FlaxTopKLogitsWarper(top_k=1      ,filter_value=0.0      ,min_tokens_to_keep=3 )

							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      np.broadcast_to(np.arange(snake_case__ )[None, :]      ,(batch_size, length) ).copy()
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      top_k_warp_safety_check(snake_case__      ,snake_case__      ,cur_len=snake_case__ )

							# min_tokens overwrites k: 3 tokens are kept => 2 tokens are nullified
							self.assertListEqual((scores == 0.0).sum(axis=-1 ).tolist()      ,[2, 2] )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      None
							SCREAMING_SNAKE_CASE_   : str					  =      10
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      2

							# create distribution and take log (inverse to Softmax as taken in TopPLogitsWarper)
							SCREAMING_SNAKE_CASE_   : Any					  =      np.log(np.array([[0.3, 0.1, 0.1, 0.5], [0.15, 0.3, 0.3, 0.25]] ) )

							SCREAMING_SNAKE_CASE_   : Dict					  =      FlaxTopPLogitsWarper(0.8 )
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      np.exp(top_p_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ ) )

							# dist should be filtered to keep min num values so that sum is >= top_p
							# exp (-inf) => 0
							SCREAMING_SNAKE_CASE_   : str					  =      np.array([[0.3, 0.0, 0.0, 0.5], [0.0, 0.3, 0.3, 0.25]] )
							self.assertTrue(np.allclose(snake_case__      ,snake_case__      ,atol=1E-3 ) )

							# check edge cases with negative and extreme logits
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      np.broadcast_to(np.arange(snake_case__ )[None, :]      ,(batch_size, vocab_size) ).copy() - (
							    vocab_size // 2
							)

							# make ramp_logits more extreme
							SCREAMING_SNAKE_CASE_   : Any					  =      ramp_logits[1] * 100.0

							# make sure at least 2 tokens are kept
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      FlaxTopPLogitsWarper(0.9      ,min_tokens_to_keep=2      ,filter_value=0.0 )
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      top_p_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )

							# first batch should keep three tokens, second batch would keep only 1, but due to `min_tokens_to_keep=2` keeps 2.
							self.assertListEqual((filtered_dist != 0.0).sum(axis=-1 ).tolist()      ,[3, 2] )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : int					  =      20
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      4
							SCREAMING_SNAKE_CASE_   : str					  =      0

							SCREAMING_SNAKE_CASE_   : str					  =      FlaxMinLengthLogitsProcessor(min_length=10      ,eos_token_id=snake_case__ )

							# check that min length is applied at length 5
							SCREAMING_SNAKE_CASE_   : Dict					  =      ids_tensor((batch_size, 20)      ,vocab_size=20 )
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      5
							SCREAMING_SNAKE_CASE_   : List[str]					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : Any					  =      min_dist_processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							self.assertListEqual(scores_before_min_length[:, eos_token_id].tolist()      ,4 * [-float('inf' )] )

							# check that min length is not applied anymore at length 15
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : int					  =      15
							SCREAMING_SNAKE_CASE_   : Any					  =      min_dist_processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							self.assertFalse(jnp.isinf(snake_case__ ).any() )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : str					  =      20
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      4
							SCREAMING_SNAKE_CASE_   : Dict					  =      0

							SCREAMING_SNAKE_CASE_   : int					  =      FlaxForcedBOSTokenLogitsProcessor(bos_token_id=snake_case__ )

							# check that all scores are -inf except the bos_token_id score
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      ids_tensor((batch_size, 1)      ,vocab_size=20 )
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      1
							SCREAMING_SNAKE_CASE_   : str					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : Dict					  =      logits_processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							self.assertTrue(jnp.isneginf(scores[:, bos_token_id + 1 :] ).all() )
							self.assertListEqual(scores[:, bos_token_id].tolist()      ,4 * [0] )  # score for bos_token_id shold be zero

							# check that bos_token_id is not forced if current length is greater than 1
							SCREAMING_SNAKE_CASE_   : Dict					  =      3
							SCREAMING_SNAKE_CASE_   : Dict					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      logits_processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							self.assertFalse(jnp.isinf(snake_case__ ).any() )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : Dict					  =      20
							SCREAMING_SNAKE_CASE_   : Any					  =      4
							SCREAMING_SNAKE_CASE_   : int					  =      0
							SCREAMING_SNAKE_CASE_   : Tuple					  =      5

							SCREAMING_SNAKE_CASE_   : List[Any]					  =      FlaxForcedEOSTokenLogitsProcessor(max_length=snake_case__      ,eos_token_id=snake_case__ )

							# check that all scores are -inf except the eos_token_id when max_length is reached
							SCREAMING_SNAKE_CASE_   : Any					  =      ids_tensor((batch_size, 4)      ,vocab_size=20 )
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      4
							SCREAMING_SNAKE_CASE_   : Dict					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : Dict					  =      logits_processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							self.assertTrue(jnp.isneginf(scores[:, eos_token_id + 1 :] ).all() )
							self.assertListEqual(scores[:, eos_token_id].tolist()      ,4 * [0] )  # score for eos_token_id should be zero

							# check that eos_token_id is not forced if max_length is not reached
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      3
							SCREAMING_SNAKE_CASE_   : int					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      logits_processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							self.assertFalse(jnp.isinf(snake_case__ ).any() )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : Dict					  =      4
							SCREAMING_SNAKE_CASE_   : Dict					  =      10
							SCREAMING_SNAKE_CASE_   : int					  =      15
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      2
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      1
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      15

							# dummy input_ids and scores
							SCREAMING_SNAKE_CASE_   : Any					  =      ids_tensor((batch_size, sequence_length)      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : int					  =      input_ids.copy()

							SCREAMING_SNAKE_CASE_   : str					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : Dict					  =      scores.copy()

							# instantiate all dist processors
							SCREAMING_SNAKE_CASE_   : int					  =      FlaxTemperatureLogitsWarper(temperature=0.5 )
							SCREAMING_SNAKE_CASE_   : int					  =      FlaxTopKLogitsWarper(3 )
							SCREAMING_SNAKE_CASE_   : Dict					  =      FlaxTopPLogitsWarper(0.8 )

							# instantiate all logits processors
							SCREAMING_SNAKE_CASE_   : Any					  =      FlaxMinLengthLogitsProcessor(min_length=10      ,eos_token_id=snake_case__ )
							SCREAMING_SNAKE_CASE_   : Any					  =      FlaxForcedBOSTokenLogitsProcessor(bos_token_id=snake_case__ )
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      FlaxForcedEOSTokenLogitsProcessor(max_length=snake_case__      ,eos_token_id=snake_case__ )

							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      10

							# no processor list
							SCREAMING_SNAKE_CASE_   : Optional[int]					  =      temp_dist_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							SCREAMING_SNAKE_CASE_   : List[str]					  =      top_k_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      top_p_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							SCREAMING_SNAKE_CASE_   : str					  =      min_dist_proc(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      bos_dist_proc(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
							SCREAMING_SNAKE_CASE_   : Tuple					  =      eos_dist_proc(snake_case__      ,snake_case__      ,cur_len=snake_case__ )

							# with processor list
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      FlaxLogitsProcessorList(
							    [temp_dist_warp, top_k_warp, top_p_warp, min_dist_proc, bos_dist_proc, eos_dist_proc] )
							SCREAMING_SNAKE_CASE_   : Any					  =      processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )

							# scores should be equal
							self.assertTrue(jnp.allclose(snake_case__      ,snake_case__      ,atol=1E-3 ) )

							# input_ids should never be changed
							self.assertListEqual(input_ids.tolist()      ,input_ids_comp.tolist() )






				def 		snake_case	(			self ):
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      4
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      10
							SCREAMING_SNAKE_CASE_   : Dict					  =      15
							SCREAMING_SNAKE_CASE_   : Dict					  =      2
							SCREAMING_SNAKE_CASE_   : Tuple					  =      1
							SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      15

							# dummy input_ids and scores
							SCREAMING_SNAKE_CASE_   : List[Any]					  =      ids_tensor((batch_size, sequence_length)      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : int					  =      input_ids.copy()

							SCREAMING_SNAKE_CASE_   : List[Any]					  =      self._get_uniform_logits(snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      scores.copy()

							# instantiate all dist processors
							SCREAMING_SNAKE_CASE_   : str					  =      FlaxTemperatureLogitsWarper(temperature=0.5 )
							SCREAMING_SNAKE_CASE_   : List[str]					  =      FlaxTopKLogitsWarper(3 )
							SCREAMING_SNAKE_CASE_   : int					  =      FlaxTopPLogitsWarper(0.8 )

							# instantiate all logits processors
							SCREAMING_SNAKE_CASE_   : Tuple					  =      FlaxMinLengthLogitsProcessor(min_length=10      ,eos_token_id=snake_case__ )
							SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      FlaxForcedBOSTokenLogitsProcessor(bos_token_id=snake_case__ )
							SCREAMING_SNAKE_CASE_   : str					  =      FlaxForcedEOSTokenLogitsProcessor(max_length=snake_case__      ,eos_token_id=snake_case__ )

							SCREAMING_SNAKE_CASE_   : List[str]					  =      10

							# no processor list
							def run_no_processor_list(snake_case__      ,snake_case__      ,snake_case__ ):
										SCREAMING_SNAKE_CASE_   : int					  =      temp_dist_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										SCREAMING_SNAKE_CASE_   : int					  =      top_k_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      top_p_warp(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      min_dist_proc(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      bos_dist_proc(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										SCREAMING_SNAKE_CASE_   : Optional[int]					  =      eos_dist_proc(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										return scores

							# with processor list
							def run_processor_list(snake_case__      ,snake_case__      ,snake_case__ ):
										SCREAMING_SNAKE_CASE_   : List[Any]					  =      FlaxLogitsProcessorList(
										    [temp_dist_warp, top_k_warp, top_p_warp, min_dist_proc, bos_dist_proc, eos_dist_proc] )
										SCREAMING_SNAKE_CASE_   : List[str]					  =      processor(snake_case__      ,snake_case__      ,cur_len=snake_case__ )
										return scores

							SCREAMING_SNAKE_CASE_   : Tuple					  =      jax.jit(snake_case__ )
							SCREAMING_SNAKE_CASE_   : Any					  =      jax.jit(snake_case__ )

							SCREAMING_SNAKE_CASE_   : int					  =      jitted_run_no_processor_list(snake_case__      ,snake_case__      ,snake_case__ )
							SCREAMING_SNAKE_CASE_   : List[str]					  =      jitted_run_processor_list(snake_case__      ,snake_case__      ,snake_case__ )

							# scores should be equal
							self.assertTrue(jnp.allclose(snake_case__      ,snake_case__      ,atol=1E-3 ) )

							# input_ids should never be changed
							self.assertListEqual(input_ids.tolist()      ,input_ids_comp.tolist() )



