



'''simple docstring'''

import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow


if is_torch_available():
	import torch

	from transformers import XLMRobertaModel


@require_sentencepiece
@require_tokenizers
@require_torch
class 	a__     (				unittest.TestCase	):


	@slow
	def 				lowercase__  (self : Tuple      )     ->			Union[str, Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						List[Any]      					= XLMRobertaModel.from_pretrained('''xlm-roberta-base'''      )
					SCREAMING_SNAKE_CASE  :						List[Any]      					= torch.tensor([[0, 581, 10269, 83, 99942, 136, 60742, 23, 70, 80583, 18276, 2]]      )
					# The dog is cute and lives in the garden house

					SCREAMING_SNAKE_CASE  :						Optional[int]      					= torch.Size((1, 12, 768)      )  # batch_size, sequence_length, embedding_vector_dim
					SCREAMING_SNAKE_CASE  :						List[str]      					= torch.tensor(
					    [[-0.0101, 0.1218, -0.0803, 0.0801, 0.1327, 0.0776, -0.1215, 0.2383, 0.3338, 0.3106, 0.0300, 0.0252]]      )
					#  xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.base')
					#  xlmr.eval()
					#  expected_output_values_last_dim = xlmr.extract_features(input_ids[0])[:, :, -1]
					with torch.no_grad():
									SCREAMING_SNAKE_CASE  :						List[Any]      					= model(__UpperCAmelCase      )['''last_hidden_state'''].detach()
					self.assertEqual(output.shape,					__UpperCAmelCase      )
					# compare the actual values for a slice of last dim
					self.assertTrue(torch.allclose(output[:, :, -1],					__UpperCAmelCase,					atol=1e-3      )      )






	@slow
	def 				lowercase__  (self : Any      )     ->			List[Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= XLMRobertaModel.from_pretrained('''xlm-roberta-large'''      )
					SCREAMING_SNAKE_CASE  :						Tuple      					= torch.tensor([[0, 581, 10269, 83, 99942, 136, 60742, 23, 70, 80583, 18276, 2]]      )
					# The dog is cute and lives in the garden house

					SCREAMING_SNAKE_CASE  :						List[str]      					= torch.Size((1, 12, 1024)      )  # batch_size, sequence_length, embedding_vector_dim
					SCREAMING_SNAKE_CASE  :						List[Any]      					= torch.tensor(
					    [[-0.0699, -0.0318, 0.0705, -0.1241, 0.0999, -0.0520, 0.1004, -0.1838, -0.4704, 0.1437, 0.0821, 0.0126]]      )
					#  xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large')
					#  xlmr.eval()
					#  expected_output_values_last_dim = xlmr.extract_features(input_ids[0])[:, :, -1]
					with torch.no_grad():
									SCREAMING_SNAKE_CASE  :						Optional[Any]      					= model(__UpperCAmelCase      )['''last_hidden_state'''].detach()
					self.assertEqual(output.shape,					__UpperCAmelCase      )
					# compare the actual values for a slice of last dim
					self.assertTrue(torch.allclose(output[:, :, -1],					__UpperCAmelCase,					atol=1e-3      )      )









'''simple docstring'''

import os
from datetime import datetime as dt

from github import Github


snake_case_			=     [
    """good first issue""",
    """good second issue""",
    """good difficult issue""",
    """enhancement""",
    """new pipeline/model""",
    """new scheduler""",
    """wip""",
]






def       __lowercase  ():
				SCREAMING_SNAKE_CASE  :						List[Any]      					= Github(os.environ['''GITHUB_TOKEN''']       )
				SCREAMING_SNAKE_CASE  :						List[str]      					= g.get_repo('''huggingface/diffusers'''       )
				SCREAMING_SNAKE_CASE  :						List[str]      					= repo.get_issues(state='''open'''       )

				for issue in open_issues:
								SCREAMING_SNAKE_CASE  :						List[Any]      					= sorted(issue.get_comments()    ,	key=lambda _SCREAMING_SNAKE_CASE       : i.created_at    ,	reverse=_SCREAMING_SNAKE_CASE       )
								SCREAMING_SNAKE_CASE  :						Optional[int]      					= comments[0] if len(_SCREAMING_SNAKE_CASE       ) > 0 else None
								if (
								    last_comment is not None
								    and last_comment.user.login == "github-actions[bot]"
								    and (dt.utcnow() - issue.updated_at).days > 7
								    and (dt.utcnow() - issue.created_at).days >= 30
								    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()       )
								):
												# Closes the issue after 7 days of inactivity since the Stalebot notification.
												issue.edit(state='''closed'''       )
								elif (
								    "stale" in issue.get_labels()
								    and last_comment is not None
								    and last_comment.user.login != "github-actions[bot]"
								):
												# Opens the issue if someone other than Stalebot commented.
												issue.edit(state='''open'''       )
												issue.remove_from_labels('''stale'''       )
								elif (
								    (dt.utcnow() - issue.updated_at).days > 23
								    and (dt.utcnow() - issue.created_at).days >= 30
								    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()       )
								):
												# Post a Stalebot notification after 23 days of inactivity.
												issue.create_comment(
												    '''This issue has been automatically marked as stale because it has not had '''
												    '''recent activity. If you think this still needs to be addressed '''
												    '''please comment on this thread.\n\nPlease note that issues that do not follow the '''
												    '''[contributing guidelines](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md) '''
												    '''are likely to be ignored.'''       )
												issue.add_to_labels('''stale'''       )


if __name__ == "__main__":
	main()




