




'''simple docstring'''


import unittest

import numpy as np

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

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import VivitImageProcessor





class    __lowercase						(  unittest.TestCase ):







   def __init__(	self      ,							UpperCamelCase      ,							UpperCamelCase=7      ,							UpperCamelCase=3      ,							UpperCamelCase=10      ,							UpperCamelCase=18      ,							UpperCamelCase=30      ,							UpperCamelCase=400      ,							UpperCamelCase=True      ,							UpperCamelCase=None      ,							UpperCamelCase=True      ,							UpperCamelCase=[0.5, 0.5, 0.5]      ,							UpperCamelCase=[0.5, 0.5, 0.5]      ,							UpperCamelCase=None      ,							)				->    str:
     __a			=					size if size is not None else {'shortest_edge': 18}
     __a			=					crop_size if crop_size is not None else {'height': 18, 'width': 18}

     __a			=					parent
     __a			=					batch_size
     __a			=					num_channels
     __a			=					num_frames
     __a			=					image_size
     __a			=					min_resolution
     __a			=					max_resolution
     __a			=					do_resize
     __a			=					size
     __a			=					do_normalize
     __a			=					image_mean
     __a			=					image_std
     __a			=					crop_size







   def 		UpperCamelCase__			(	self      )				->    str:
     return {
         "image_mean": self.image_mean,
         "image_std": self.image_std,
         "do_normalize": self.do_normalize,
         "do_resize": self.do_resize,
         "size": self.size,
         "crop_size": self.crop_size,
     }





@require_torch
@require_vision
class    __lowercase						(  __magic_name__       ,							unittest.TestCase ):
   _a							=      VivitImageProcessor if is_vision_available() else None







   def 		UpperCamelCase__			(	self      )				->    Any:
     __a			=					VivitImageProcessingTester(self      )







   @property
   def 		UpperCamelCase__			(	self      )				->    str:
     return self.image_processor_tester.prepare_image_processor_dict()







   def 		UpperCamelCase__			(	self      )				->    int:
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     self.assertTrue(hasattr(UpperCamelCase      ,							'image_mean'      )      )
     self.assertTrue(hasattr(UpperCamelCase      ,							'image_std'      )      )
     self.assertTrue(hasattr(UpperCamelCase      ,							'do_normalize'      )      )
     self.assertTrue(hasattr(UpperCamelCase      ,							'do_resize'      )      )
     self.assertTrue(hasattr(UpperCamelCase      ,							'do_center_crop'      )      )
     self.assertTrue(hasattr(UpperCamelCase      ,							'size'      )      )







   def 		UpperCamelCase__			(	self      )				->    Optional[Any]:
     __a			=					self.image_processing_class.from_dict(self.image_processor_dict      )
     self.assertEqual(image_processor.size      ,							{'shortest_edge': 18}      )
     self.assertEqual(image_processor.crop_size      ,							{'height': 18, 'width': 18}      )

     __a			=					self.image_processing_class.from_dict(self.image_processor_dict      ,							size=42      ,							crop_size=84      )
     self.assertEqual(image_processor.size      ,							{'shortest_edge': 42}      )
     self.assertEqual(image_processor.crop_size      ,							{'height': 84, 'width': 84}      )







   def 		UpperCamelCase__			(	self      )				->    Union[str, Any]:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random PIL videos
     __a			=					prepare_video_inputs(self.image_processor_tester      ,							equal_resolution=UpperCamelCase      )
     for video in video_inputs:
       self.assertIsInstance(UpperCamelCase      ,							UpperCamelCase      )
       self.assertIsInstance(video[0]      ,							Image.Image      )

     # Test not batched input
     __a			=					image_processing(video_inputs[0]      ,							return_tensors='pt'      ).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,							(
             1,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['height'],
             self.image_processor_tester.crop_size['width'],
         )      ,							)

     # Test batched
     __a			=					image_processing(UpperCamelCase      ,							return_tensors='pt'      ).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,							(
             self.image_processor_tester.batch_size,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['height'],
             self.image_processor_tester.crop_size['width'],
         )      ,							)







   def 		UpperCamelCase__			(	self      )				->    Tuple:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random numpy tensors
     __a			=					prepare_video_inputs(self.image_processor_tester      ,							equal_resolution=UpperCamelCase      ,							numpify=UpperCamelCase      )
     for video in video_inputs:
       self.assertIsInstance(UpperCamelCase      ,							UpperCamelCase      )
       self.assertIsInstance(video[0]      ,							np.ndarray      )

     # Test not batched input
     __a			=					image_processing(video_inputs[0]      ,							return_tensors='pt'      ).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,							(
             1,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['height'],
             self.image_processor_tester.crop_size['width'],
         )      ,							)

     # Test batched
     __a			=					image_processing(UpperCamelCase      ,							return_tensors='pt'      ).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,							(
             self.image_processor_tester.batch_size,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['height'],
             self.image_processor_tester.crop_size['width'],
         )      ,							)







   def 		UpperCamelCase__			(	self      )				->    int:
     # Initialize image_processing
     __a			=					self.image_processing_class(**self.image_processor_dict      )
     # create random PyTorch tensors
     __a			=					prepare_video_inputs(self.image_processor_tester      ,							equal_resolution=UpperCamelCase      ,							torchify=UpperCamelCase      )
     for video in video_inputs:
       self.assertIsInstance(UpperCamelCase      ,							UpperCamelCase      )
       self.assertIsInstance(video[0]      ,							torch.Tensor      )

     # Test not batched input
     __a			=					image_processing(video_inputs[0]      ,							return_tensors='pt'      ).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,							(
             1,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['height'],
             self.image_processor_tester.crop_size['width'],
         )      ,							)

     # Test batched
     __a			=					image_processing(UpperCamelCase      ,							return_tensors='pt'      ).pixel_values
     self.assertEqual(
         encoded_videos.shape      ,							(
             self.image_processor_tester.batch_size,
             self.image_processor_tester.num_frames,
             self.image_processor_tester.num_channels,
             self.image_processor_tester.crop_size['height'],
             self.image_processor_tester.crop_size['width'],
         )      ,							)









'''simple docstring'''


import os
from datetime import datetime as dt

from github import Github


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


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

  for issue in open_issues:
    __a			=					sorted(issue.get_comments()				,					key=lambda a_			: i.created_at				,					reverse=a_			)
    __a			=					comments[0] if len(a_			) > 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()



