




from datetime import datetime as dt
import os

from github import Github


_snake_case            = [
    "good first issue",
    "good second issue",
    "good difficult issue",
    "feature request",
    "new model",
    "wip",
]







def        lowerCAmelCase_			(  ):
      _A							:  int    =		Github(os.environ["""GITHUB_TOKEN"""]  )
      _A							:  Tuple    =		g.get_repo("""huggingface/transformers"""  )
      _A							:  Dict    =		repo.get_issues(state="""open"""  )

      for issue in open_issues:
            _A							:  Optional[Any]    =		sorted([comment for comment in issue.get_comments()],key=lambda snake_case_  : i.created_at,reverse=snake_case_  )
            _A							:  Dict    =		comments[0] if len(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()  )
            ):
                  # print(f"Would close issue {issue.number} since it has been 7 days of inactivity since bot mention.")
                  issue.edit(state="""closed"""  )
            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()  )
            ):
                  # print(f"Would add stale comment to {issue.number}")
                  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/transformers/blob/main/CONTRIBUTING.md) """
                      """are likely to be ignored."""  )


if __name__ == "__main__":
  main()







import unittest

import numpy as np

from transformers.file_utils import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import DPTImageProcessor







class 		lowercase							(     unittest.TestCase	):

     def __init__(						self	,  _a	,  _a=7	,  _a=3	,  _a=18	,  _a=30	,  _a=400	,  _a=True	,  _a=None	,  _a=True	,  _a=[0.5, 0.5, 0.5]	,  _a=[0.5, 0.5, 0.5]	,  )		->							Tuple:
           _A							:  Any    =		size if size is not None else {"""height""": 18, """width""": 18}
           _A							:  Optional[Any]    =		parent
           _A							:  Union[str, Any]    =		batch_size
           _A							:  List[Any]    =		num_channels
           _A							:  List[str]    =		image_size
           _A							:  Optional[Any]    =		min_resolution
           _A							:  List[Any]    =		max_resolution
           _A							:  Optional[Any]    =		do_resize
           _A							:  str    =		size
           _A							:  List[str]    =		do_normalize
           _A							:  Dict    =		image_mean
           _A							:  int    =		image_std



     def       a__			(						self       )		->							Any:
           return {
               "image_mean": self.image_mean,
               "image_std": self.image_std,
               "do_normalize": self.do_normalize,
               "do_resize": self.do_resize,
               "size": self.size,
           }







@require_torch
@require_vision
class 		lowercase							(     UpperCamelCase__,unittest.TestCase	):
     _a											=		DPTImageProcessor if is_vision_available() else None

     def       a__			(						self       )		->							Optional[int]:
           _A							:  Optional[Any]    =		DPTImageProcessingTester(self       )

     @property
     def       a__			(						self       )		->							Tuple:
           return self.image_processor_tester.prepare_image_processor_dict()

     def       a__			(						self       )		->							Any:
           _A							:  List[str]    =		self.image_processing_class(**self.image_processor_dict       )
           self.assertTrue(hasattr(_a	,  """image_mean"""       )       )
           self.assertTrue(hasattr(_a	,  """image_std"""       )       )
           self.assertTrue(hasattr(_a	,  """do_normalize"""       )       )
           self.assertTrue(hasattr(_a	,  """do_resize"""       )       )
           self.assertTrue(hasattr(_a	,  """size"""       )       )

     def       a__			(						self       )		->							Any:
           _A							:  List[str]    =		self.image_processing_class.from_dict(self.image_processor_dict       )
           self.assertEqual(image_processor.size	,  {"""height""": 18, """width""": 18}       )

           _A							:  str    =		self.image_processing_class.from_dict(self.image_processor_dict	,  size=42       )
           self.assertEqual(image_processor.size	,  {"""height""": 42, """width""": 42}       )

     def       a__			(						self       )		->							List[Any]:
           # Initialize image_processing
           _A							:  Optional[int]    =		self.image_processing_class(**self.image_processor_dict       )
           # create random PIL images
           _A							:  Any    =		prepare_image_inputs(self.image_processor_tester	,  equal_resolution=_a       )
           for image in image_inputs:
                 self.assertIsInstance(_a	,  Image.Image       )

           # Test not batched input
           _A							:  Union[str, Any]    =		image_processing(image_inputs[0]	,  return_tensors="""pt"""       ).pixel_values
           self.assertEqual(
               encoded_images.shape	,  (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )	,  )

           # Test batched
           _A							:  int    =		image_processing(_a	,  return_tensors="""pt"""       ).pixel_values
           self.assertEqual(
               encoded_images.shape	,  (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )	,  )

     def       a__			(						self       )		->							Union[str, Any]:
           # Initialize image_processing
           _A							:  List[Any]    =		self.image_processing_class(**self.image_processor_dict       )
           # create random numpy tensors
           _A							:  Optional[Any]    =		prepare_image_inputs(self.image_processor_tester	,  equal_resolution=_a	,  numpify=_a       )
           for image in image_inputs:
                 self.assertIsInstance(_a	,  np.ndarray       )

           # Test not batched input
           _A							:  Dict    =		image_processing(image_inputs[0]	,  return_tensors="""pt"""       ).pixel_values
           self.assertEqual(
               encoded_images.shape	,  (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )	,  )

           # Test batched
           _A							:  Any    =		image_processing(_a	,  return_tensors="""pt"""       ).pixel_values
           self.assertEqual(
               encoded_images.shape	,  (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )	,  )



     def       a__			(						self       )		->							List[str]:
           # Initialize image_processing
           _A							:  Dict    =		self.image_processing_class(**self.image_processor_dict       )
           # create random PyTorch tensors
           _A							:  str    =		prepare_image_inputs(self.image_processor_tester	,  equal_resolution=_a	,  torchify=_a       )
           for image in image_inputs:
                 self.assertIsInstance(_a	,  torch.Tensor       )

           # Test not batched input
           _A							:  Optional[Any]    =		image_processing(image_inputs[0]	,  return_tensors="""pt"""       ).pixel_values
           self.assertEqual(
               encoded_images.shape	,  (
                   1,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )	,  )

           # Test batched
           _A							:  int    =		image_processing(_a	,  return_tensors="""pt"""       ).pixel_values
           self.assertEqual(
               encoded_images.shape	,  (
                   self.image_processor_tester.batch_size,
                   self.image_processor_tester.num_channels,
                   self.image_processor_tester.size["""height"""],
                   self.image_processor_tester.size["""width"""],
               )	,  )

