




"""simple docstring"""






from importlib import import_module

from .logging import get_logger


UpperCamelCase__						=			get_logger(__name__)




class   a__			:





						def __init__(							self      :	List[str]     ,a__      :	List[str]     ,a__      :	List[Any]=None)						->       Any:




											"""simple docstring"""







											_lowerCAmelCase:Any									=  attrs or []
											if module is not None:
																for key in module.__dict__:
																					if key in attrs or not key.startswith('''__'''):
																										setattr(self     ,a__     ,getattr(a__     ,a__))
											_lowerCAmelCase:List[Any]									=  module._original_module if isinstance(a__     ,_PatchedModuleObj) else module




class   a__			:
						snake_case__             = []





						def __init__(							self      :	Any     ,a__      :	Any     ,a__      :	str     ,a__      :	str     ,a__      :	Tuple=None)						->       Dict:




											"""simple docstring"""







											_lowerCAmelCase:Optional[int]									=  obj
											_lowerCAmelCase:Optional[int]									=  target
											_lowerCAmelCase:Any									=  new
											_lowerCAmelCase:Tuple									=  target.split('''.''')[0]
											_lowerCAmelCase:List[str]									=  {}
											_lowerCAmelCase:List[str]									=  attrs or []





						def __enter__(							self      :	Tuple)						->       str:




											"""simple docstring"""







											*_lowerCAmelCase							,   _lowerCAmelCase:Union[str, Any]									=  self.target.split('''.''')

											# Patch modules:
											# it's used to patch attributes of submodules like "os.path.join";
											# in this case we need to patch "os" and "os.path"

											for i in range(len(a__)):
																try:
																					_lowerCAmelCase:Any									=  import_module('''.'''.join(submodules[: i + 1]))
																except ModuleNotFoundError:
																					continue
																# We iterate over all the globals in self.obj in case we find "os" or "os.path"
																for attr in self.obj.__dir__():
																					_lowerCAmelCase:Union[str, Any]									=  getattr(self.obj     ,a__)
																					# We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
																					# This allows to patch renamed modules like "from os import path as ospath".
																					if obj_attr is submodule or (
																					    (isinstance(a__     ,_PatchedModuleObj) and obj_attr._original_module is submodule)
																					):
																										_lowerCAmelCase:int									=  obj_attr
																										# patch at top level
																										setattr(self.obj     ,a__     ,_PatchedModuleObj(a__     ,attrs=self.attrs))
																										_lowerCAmelCase:str									=  getattr(self.obj     ,a__)
																										# construct lower levels patches
																										for key in submodules[i + 1 :]:
																															setattr(a__     ,a__     ,_PatchedModuleObj(getattr(a__     ,a__     ,a__)     ,attrs=self.attrs))
																															_lowerCAmelCase:Optional[Any]									=  getattr(a__     ,a__)
																										# finally set the target attribute
																										setattr(a__     ,a__     ,self.new)

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

											if submodules:  # if it's an attribute of a submodule like "os.path.join"
																try:
																					_lowerCAmelCase:Tuple									=  getattr(import_module('''.'''.join(a__))     ,a__)
																except (AttributeError, ModuleNotFoundError):
																					return
																# We iterate over all the globals in self.obj in case we find "os.path.join"
																for attr in self.obj.__dir__():
																					# We don't check for the name of the global, but rather if its value *is* "os.path.join".
																					# This allows to patch renamed attributes like "from os.path import join as pjoin".
																					if getattr(self.obj     ,a__) is attr_value:
																										_lowerCAmelCase:List[Any]									=  getattr(self.obj     ,a__)
																										setattr(self.obj     ,a__     ,self.new)
											elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
																_lowerCAmelCase:Tuple									=  globals()['''__builtins__'''][target_attr]
																setattr(self.obj     ,a__     ,self.new)
											else:
																raise RuntimeError(F'Tried to patch attribute {target_attr} instead of a submodule.')





						def __exit__(							self      :	str     ,*a__      :	Tuple)						->       int:




											"""simple docstring"""







											for attr in list(self.original):
																setattr(self.obj     ,a__     ,self.original.pop(a__))





						def       __UpperCamelCase     (							self      :	Optional[int])						->       Optional[Any]:




											"""simple docstring"""







											self.__enter__()
											self._active_patches.append(self)







						def       __UpperCamelCase     (							self      :	Tuple)						->       Union[str, Any]:




											"""simple docstring"""







											try:
																self._active_patches.remove(self)
											except ValueError:
																# If the patch hasn't been started this will fail
																return None

											return self.__exit__()












"""simple docstring"""






from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import torch

from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available




@dataclass
class   a__			(       UpperCamelCase_  ):
						snake_case__             = 42


try:
				if not (is_transformers_available() and is_torch_available()):
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
				from .pipeline_text_to_video_synth import TextToVideoSDPipeline
				from .pipeline_text_to_video_synth_imgaimg import VideoToVideoSDPipeline  # noqa: F401
				from .pipeline_text_to_video_zero import TextToVideoZeroPipeline






