"""simple docstring"""






# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import doctest
import sys
import warnings
from os.path import abspath, dirname, join

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
_A   					=    abspath(join(dirname(__file__), 'src'))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='ignore', category=FutureWarning)




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   int:
				config.addinivalue_line(
				    "markers"  ,					"is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested"       )
				config.addinivalue_line(
				    "markers"  ,					"is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested"       )
				config.addinivalue_line("markers"  ,					"is_pipeline_test: mark test to run only when pipelines are tested"       )
				config.addinivalue_line("markers"  ,					"is_staging_test: mark test to run only in the staging environment"       )
				config.addinivalue_line("markers"  ,					"accelerate_tests: mark test that require accelerate"       )
				config.addinivalue_line("markers"  ,					"tool_tests: mark the tool tests that are run on their specific schedule"       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Tuple:
				from transformers.testing_utils import pytest_addoption_shared

				pytest_addoption_shared(__UpperCAmelCase       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Dict:
				from transformers.testing_utils import pytest_terminal_summary_main

				SCREAMING_SNAKE_CASE__		  =				terminalreporter.config.getoption("--make-reports"       )
				if make_reports:
								pytest_terminal_summary_main(__UpperCAmelCase  ,					id=__UpperCAmelCase       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__UpperCAmelCase       )							->   Dict:
				# If no tests are collected, pytest exists with code 5, which makes the CI fail.
				if exitstatus == 5:
								SCREAMING_SNAKE_CASE__		  =				0


# Doctest custom flag to ignore output.
_A   					=    doctest.register_optionflag('IGNORE_RESULT')

_A   					=    doctest.OutputChecker

class lowerCamelCase		(_SCREAMING_SNAKE_CASE      ):






					'''simple docstring'''


					def 			lowerCAmelCase_					(						self			:				List[Any]   , _snake_case			:				Union[str, Any]   , _snake_case			:				Optional[Any]   , _snake_case			:				Optional[Any]		)							->       Dict:
									if IGNORE_RESULT & optionflags:
													return True
									return OutputChecker.check_output(self   , _snake_case   , _snake_case   , _snake_case		)



_A   					=    CustomOutputChecker
_A   					=    HfDoctestModule

_A   					=    HfDocTestParser





"""simple docstring"""






def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   List[str]:
				if not head:
								return True
				# split the list to two parts
				SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				head.next, head
				while fast and fast.next:
								SCREAMING_SNAKE_CASE__		  =				fast.next.next
								SCREAMING_SNAKE_CASE__		  =				slow.next
				SCREAMING_SNAKE_CASE__		  =				slow.next
				SCREAMING_SNAKE_CASE__		  =				None  # Don't forget here! But forget still works!
				# reverse the second part
				SCREAMING_SNAKE_CASE__		  =				None
				while second:
								SCREAMING_SNAKE_CASE__		  =				second.next
								SCREAMING_SNAKE_CASE__		  =				node
								SCREAMING_SNAKE_CASE__		  =				second
								SCREAMING_SNAKE_CASE__		  =				nxt
				# compare two parts
				# second part has the same or one less node
				while node:
								if node.val != head.val:
												return False
								SCREAMING_SNAKE_CASE__		  =				node.next
								SCREAMING_SNAKE_CASE__		  =				head.next
				return True




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   str:
				if not head or not head.next:
								return True

				# 1. Get the midpoint (slow)
				SCREAMING_SNAKE_CASE__		  =				SCREAMING_SNAKE_CASE__		  =				SCREAMING_SNAKE_CASE__		  =				head
				while fast and fast.next:
								SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				fast.next.next, slow.next

				# 2. Push the second half into the stack
				SCREAMING_SNAKE_CASE__		  =				[slow.val]
				while slow.next:
								SCREAMING_SNAKE_CASE__		  =				slow.next
								stack.append(slow.val       )

				# 3. Comparison
				while stack:
								if stack.pop() != cur.val:
												return False
								SCREAMING_SNAKE_CASE__		  =				cur.next

				return True




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   str:
				if not head or not head.next:
								return True
				SCREAMING_SNAKE_CASE__		  =				{}
				SCREAMING_SNAKE_CASE__		  =				0
				while head:
								if head.val in d:
												d[head.val].append(__UpperCAmelCase       )
								else:
												SCREAMING_SNAKE_CASE__		  =				[pos]
								SCREAMING_SNAKE_CASE__		  =				head.next
								pos += 1
				SCREAMING_SNAKE_CASE__		  =				pos - 1
				SCREAMING_SNAKE_CASE__		  =				0
				for v in d.values():
								if len(__UpperCAmelCase       ) % 2 != 0:
												middle += 1
								else:
												SCREAMING_SNAKE_CASE__		  =				0
												for i in range(0  ,					len(__UpperCAmelCase       )       ):
																if v[i] + v[len(__UpperCAmelCase       ) - 1 - step] != checksum:
																				return False
																step += 1
								if middle > 1:
												return False
				return True




