



"""simple docstring"""

from dataclasses import dataclass
from typing import Optional

import torch
from torch import nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .attention import BasicTransformerBlock
from .modeling_utils import ModelMixin




@dataclass
class        _UpperCAmelCase       (			lowerCAmelCase__):
 _lowerCAmelCase   :			torch.FloatTensor





class        _UpperCAmelCase       (			lowerCAmelCase__    ,     lowerCAmelCase__):

 @register_to_config
 def __init__(     self		:       Dict  ,     lowercase_		:       int = 16  ,     lowercase_		:       int = 88  ,     lowercase_		:       Optional[int] = None  ,     lowercase_		:       Optional[int] = None  ,     lowercase_		:       int = 1  ,     lowercase_		:       float = 0.0  ,     lowercase_		:       int = 32  ,     lowercase_		:       Optional[int] = None  ,     lowercase_		:       bool = False  ,     lowercase_		:       Optional[int] = None  ,     lowercase_		:       str = "geglu"  ,     lowercase_		:       bool = True  ,     lowercase_		:       bool = True  ,     ):
     super().__init__()
     snake_case_ :     Tuple				=	num_attention_heads
     snake_case_ :     int				=	attention_head_dim
     snake_case_ :     List[Any]				=	num_attention_heads * attention_head_dim

     snake_case_ :     Tuple				=	in_channels

     snake_case_ :     List[Any]				=	torch.nn.GroupNorm(num_groups=lowercase_  ,     num_channels=lowercase_  ,     eps=1E-6  ,     affine=lowercase_				)
     snake_case_ :     int				=	nn.Linear(lowercase_  ,     lowercase_				)

     # 3. Define transformers blocks
     snake_case_ :     Optional[int]				=	nn.ModuleList(
         [
             BasicTransformerBlock(
                 lowercase_  ,     lowercase_  ,     lowercase_  ,     dropout=lowercase_  ,     cross_attention_dim=lowercase_  ,     activation_fn=lowercase_  ,     attention_bias=lowercase_  ,     double_self_attention=lowercase_  ,     norm_elementwise_affine=lowercase_  ,     )
             for d in range(lowercase_				)
         ]				)

     snake_case_ :     Tuple				=	nn.Linear(lowercase_  ,     lowercase_				)






 def 						_snake_case					(     self		:       List[Any]  ,     lowercase_		:       Optional[Any]  ,     lowercase_		:       Optional[Any]=None  ,     lowercase_		:       Optional[Any]=None  ,     lowercase_		:       List[Any]=None  ,     lowercase_		:       Optional[Any]=1  ,     lowercase_		:       str=None  ,     lowercase_		:       bool = True  ,     ):
     snake_case_,	snake_case_,	snake_case_,	snake_case_ :     List[Any]				=	hidden_states.shape
     snake_case_ :     Optional[int]				=	batch_frames // num_frames

     snake_case_ :     Dict				=	hidden_states

     snake_case_ :     List[Any]				=	hidden_states[None, :].reshape(lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_				)
     snake_case_ :     Union[str, Any]				=	hidden_states.permute(0  ,     2  ,     1  ,     3  ,     4				)

     snake_case_ :     Optional[int]				=	self.norm(lowercase_				)
     snake_case_ :     Optional[int]				=	hidden_states.permute(0  ,     3  ,     4  ,     2  ,     1				).reshape(batch_size * height * width  ,     lowercase_  ,     lowercase_				)

     snake_case_ :     Any				=	self.proj_in(lowercase_				)

     # 2. Blocks
     for block in self.transformer_blocks:
         snake_case_ :     Union[str, Any]				=	block(
             lowercase_  ,     encoder_hidden_states=lowercase_  ,     timestep=lowercase_  ,     cross_attention_kwargs=lowercase_  ,     class_labels=lowercase_  ,     )

     # 3. Output
     snake_case_ :     Dict				=	self.proj_out(lowercase_				)
     snake_case_ :     Dict				=	(
         hidden_states[None, None, :]
         .reshape(lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_				)
         .permute(0  ,     3  ,     4  ,     1  ,     2				)
         .contiguous()
     )
     snake_case_ :     Union[str, Any]				=	hidden_states.reshape(lowercase_  ,     lowercase_  ,     lowercase_  ,     lowercase_				)

     snake_case_ :     Optional[int]				=	hidden_states + residual

     if not return_dict:
         return (output,)

     return TransformerTemporalModelOutput(sample=lowercase_				)










"""simple docstring"""

import os
from datetime import datetime as dt

from github import Github


lowercase__    :  int							    =	[
    '''good first issue''',
    '''good second issue''',
    '''good difficult issue''',
    '''enhancement''',
    '''new pipeline/model''',
    '''new scheduler''',
    '''wip''',
]




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

    for issue in open_issues:
        snake_case_ :     str				=	sorted(issue.get_comments()		,			key=lambda _a    : i.created_at		,			reverse=_a    )
        snake_case_ :     Dict				=	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()





