






import os
from datetime import datetime as dt

from github import Github


UpperCAmelCase__      			=						[
    '''good first issue''',
    '''feature request''',
    '''wip''',
]







def     a_   ()				->						Any:



					"""simple docstring"""
					__a					:						Union[str, Any]      =					Github(os.environ["GITHUB_TOKEN"]      )
					__a					:						Tuple      =					g.get_repo("huggingface/accelerate"      )
					__a					:						int      =					repo.get_issues(state="open"      )

					for issue in open_issues:
										__a					:						List[str]      =					sorted([comment for comment in issue.get_comments()]				,       key=lambda __A      : i.created_at				,       reverse=__A      )
										__a					:						List[Any]      =					comments[0] if len(__A      ) > 0 else None
										__a					:						Dict      =					dt.utcnow()
										__a					:						Any      =					(current_time - issue.updated_at).days
										__a					:						Optional[int]      =					(current_time - issue.created_at).days
										if (
										    last_comment is not None
										    and last_comment.user.login == "github-actions[bot]"
										    and days_since_updated > 7
										    and days_since_creation >= 30
										    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()      )
										):
															# Close issue since it has been 7 days of inactivity since bot mention.
															issue.edit(state="closed"      )
										elif (
										    days_since_updated > 23
										    and days_since_creation >= 30
										    and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()      )
										):
															# Add stale comment
															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/accelerate/blob/main/CONTRIBUTING.md) "
															    "are likely to be ignored."      )


if __name__ == "__main__":
			main()













import unittest

from transformers import is_flax_available
from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow


if is_flax_available():
			import optax
			from flax.training.common_utils import onehot

			from transformers import AutoTokenizer, FlaxMTaForConditionalGeneration
			from transformers.models.ta.modeling_flax_ta import shift_tokens_right




@require_torch
@require_sentencepiece
@require_tokenizers
@require_flax
class 							snake_case_       (    unittest.TestCase      ):

						"""simple docstring"""



						@slow
						def        UpperCAmelCase__					(self:					Optional[int]   )    ->     List[str]:




											'''simple docstring'''



											__a					:						Optional[Any]      =					FlaxMTaForConditionalGeneration.from_pretrained("google/mt5-small"   )
											__a					:						Dict      =					AutoTokenizer.from_pretrained("google/mt5-small"   )

											__a					:						Any      =					tokenizer("Hello there" ,					return_tensors="np"   ).input_ids
											__a					:						Union[str, Any]      =					tokenizer("Hi I am" ,					return_tensors="np"   ).input_ids

											__a					:						Union[str, Any]      =					shift_tokens_right(__UpperCAmelCase ,					model.config.pad_token_id ,					model.config.decoder_start_token_id   )

											__a					:						Tuple      =					model(__UpperCAmelCase ,					decoder_input_ids=__UpperCAmelCase   ).logits
											__a					:						str      =					optax.softmax_cross_entropy(__UpperCAmelCase ,					onehot(__UpperCAmelCase ,					logits.shape[-1]   )   ).mean()

											__a					:						List[str]      =					-(labels.shape[-1] * loss.item())

											__a					:						Optional[int]      =					-84.91_27
											self.assertTrue(abs(mtf_score - EXPECTED_SCORE   ) < 1E-4   )





