


'''simple docstring'''


import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
				import torch

				from transformers.generation import DisjunctiveConstraint





@require_torch
class     lowercase__  (						unittest.TestCase					):





							'''simple docstring'''


							def UpperCAmelCase_	(    self  ):
											# For consistency across different places the DisjunctiveConstraint is called,
											# dc.token_ids is a list of integers. It is also initialized only by integers.

											_SCREAMING_SNAKE_CASE :       List[str]     		=      [[1, 2, 4], [1, 2, 3, 4]]
											_SCREAMING_SNAKE_CASE :       Dict     		=      DisjunctiveConstraint(__snake_case  )
											self.assertTrue(isinstance(dc.token_ids    ,					__snake_case  )  )

											with self.assertRaises(__snake_case  ):
															DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]  )  )

											with self.assertRaises(__snake_case  ):
															DisjunctiveConstraint([torch.LongTensor([1, 2, 4]  ), torch.LongTensor([1, 2, 3, 4, 5]  )]  )






							def UpperCAmelCase_	(    self  ):
											# We can't have constraints that are complete subsets of another. This leads to a preverse
											# interpretation of "constraint fulfillment": does generating [1,2,3] fulfill the constraint?
											# It would mean that it generated [1,2] which fulfills it, but it's in the middle of potentially
											# fulfilling [1,2,3,4]. If we believe that [1,2,3] does fulfill the constraint, then the algorithm
											# will necessarily never reach [1,2,3,4], giving users a false sense of control (better to just not allow it).
											_SCREAMING_SNAKE_CASE :       Union[str, Any]     		=      [[1, 2], [1, 2, 3, 4]]

											with self.assertRaises(__snake_case  ):
															DisjunctiveConstraint(__snake_case  )  # fails here






							def UpperCAmelCase_	(    self  ):
											_SCREAMING_SNAKE_CASE :       List[Any]     		=      [[1, 2, 3], [1, 2, 4]]

											_SCREAMING_SNAKE_CASE :       Tuple     		=      DisjunctiveConstraint(__snake_case  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       List[Any]     		=      dc.update(1  )
											_SCREAMING_SNAKE_CASE :       Optional[Any]     		=      stepped is True and completed is False and reset is False
											self.assertTrue(__snake_case  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.current_seq == [1]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       str     		=      dc.update(2  )
											_SCREAMING_SNAKE_CASE :       List[str]     		=      stepped is True and completed is False and reset is False
											self.assertTrue(__snake_case  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.current_seq == [1, 2]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       Union[str, Any]     		=      dc.update(3  )
											_SCREAMING_SNAKE_CASE :       Tuple     		=      stepped is True and completed is True and reset is False
											self.assertTrue(__snake_case  )
											self.assertTrue(dc.completed  )  # Completed!
											self.assertTrue(dc.current_seq == [1, 2, 3]  )






							def UpperCAmelCase_	(    self  ):
											_SCREAMING_SNAKE_CASE :       Any     		=      [[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

											_SCREAMING_SNAKE_CASE :       List[str]     		=      DisjunctiveConstraint(__snake_case  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       Optional[int]     		=      dc.update(1  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.current_seq == [1]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       List[str]     		=      dc.update(2  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.current_seq == [1, 2]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       List[Any]     		=      dc.update(4  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.current_seq == [1, 2, 4]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       Optional[Any]     		=      dc.update(5  )
											self.assertTrue(dc.completed  )  # Completed!
											self.assertTrue(dc.current_seq == [1, 2, 4, 5]  )

											dc.reset()

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       Tuple     		=      dc.update(1  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.remaining() == 3  )
											self.assertTrue(dc.current_seq == [1]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       Optional[int]     		=      dc.update(2  )
											self.assertTrue(not dc.completed  )
											self.assertTrue(dc.remaining() == 2  )
											self.assertTrue(dc.current_seq == [1, 2]  )

											_SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE		,       _SCREAMING_SNAKE_CASE :       Optional[int]     		=      dc.update(5  )
											self.assertTrue(dc.completed  )  # Completed!
											self.assertTrue(dc.remaining() == 0  )
											self.assertTrue(dc.current_seq == [1, 2, 5]  )








'''simple docstring'''


from __future__ import annotations

import os
from typing import Any

import requests

UpperCAmelCase_		:   List[Any]							   =		'https://api.github.com'

# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user
UpperCAmelCase_		:   Optional[Any]							   =		BASE_URL + '/user'

# https://github.com/settings/tokens
UpperCAmelCase_		:   str							   =		os.environ.get('USER_TOKEN', '')







def 			snake_case_   (  SCREAMING_SNAKE_CASE__     ):







				"""simple docstring"""





				_SCREAMING_SNAKE_CASE :       Union[str, Any]     		=      {
				    """Authorization""": f"""token {auth_token}""",
				    """Accept""": """application/vnd.github.v3+json""",
				}
				return requests.get(SCREAMING_SNAKE_CASE__							,      headers=SCREAMING_SNAKE_CASE__     ).json()


if __name__ == "__main__":  # pragma: no cover
				if USER_TOKEN:
								for key, value in fetch_github_info(USER_TOKEN).items():
												print(F"{key}: {value}")
				else:
								raise ValueError('\'USER_TOKEN\' field cannot be empty.')




