




import time
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, torch_device

from ..test_modeling_common import ids_tensor


if is_torch_available():
						import torch

						from transformers.generation import (
						    MaxLengthCriteria,
						    MaxNewTokensCriteria,
						    MaxTimeCriteria,
						    StoppingCriteriaList,
						    validate_stopping_criteria,
						)


@require_torch
class  A		(  unittest.TestCase     ):



		def        SCREAMING_SNAKE_CASE__			(     self,	UpperCamelCase__   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  3
								lowerCAmelCase_      			=  250

								lowerCAmelCase_      			=  ids_tensor((batch_size, length),	UpperCamelCase__   )
								lowerCAmelCase_      			=  torch.ones((batch_size, length),	device=UpperCamelCase__,	dtype=torch.float   ) / length
								return input_ids, scores



		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(5   )

								lowerCAmelCase_      			=  StoppingCriteriaList(
								    [
								        MaxLengthCriteria(max_length=10   ),
								        MaxTimeCriteria(max_time=0.1   ),
								    ]   )

								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(9   )
								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(10   )
								self.assertTrue(criteria(UpperCamelCase__,	UpperCamelCase__   )   )



		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  MaxLengthCriteria(max_length=10   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(5   )
								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(9   )
								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(10   )
								self.assertTrue(criteria(UpperCamelCase__,	UpperCamelCase__   )   )



		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  MaxNewTokensCriteria(start_length=5,	max_new_tokens=5   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(5   )
								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(9   )
								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(10   )
								self.assertTrue(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_      			=  StoppingCriteriaList([criteria]   )
								self.assertEqual(criteria_list.max_length,	10   )



		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								lowerCAmelCase_			,					lowerCAmelCase_      			=  self._get_tensors(5   )

								lowerCAmelCase_      			=  MaxTimeCriteria(max_time=0.1   )
								self.assertFalse(criteria(UpperCamelCase__,	UpperCamelCase__   )   )

								lowerCAmelCase_      			=  MaxTimeCriteria(max_time=0.1,	initial_timestamp=time.time() - 0.2   )
								self.assertTrue(criteria(UpperCamelCase__,	UpperCamelCase__   )   )







		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								validate_stopping_criteria(StoppingCriteriaList([MaxLengthCriteria(10   )]   ),	10   )

								with self.assertWarns(UpperCamelCase__   ):
														validate_stopping_criteria(StoppingCriteriaList([MaxLengthCriteria(10   )]   ),	11   )

								lowerCAmelCase_      			=  validate_stopping_criteria(StoppingCriteriaList(),	11   )

								self.assertEqual(len(UpperCamelCase__   ),	1   )










def __UpperCamelCase			(       _A = 1000000  ):
						lowerCAmelCase_      			=  1
						lowerCAmelCase_      			=  1
						lowerCAmelCase_      			=  {1: 1}

						for inputa in range(2 ,  _A  ):
												lowerCAmelCase_      			=  0
												lowerCAmelCase_      			=  inputa

												while True:
																		if number in counters:
																								counter += counters[number]
																								break
																		if number % 2 == 0:
																								number //= 2
																								counter += 1
																		else:
																								lowerCAmelCase_      			=  (3 * number) + 1
																								counter += 1

												if inputa not in counters:
																		lowerCAmelCase_      			=  counter

												if counter > pre_counter:
																		lowerCAmelCase_      			=  inputa
																		lowerCAmelCase_      			=  counter
						return largest_number


if __name__ == "__main__":
						print(solution(int(input().strip())))




