




"""simple docstring"""






import copy
import importlib.metadata
import json
import os
from dataclasses import dataclass
from typing import Any, Dict, Union

from packaging import version

from ..utils import is_torch_available, logging


if is_torch_available():
				import torch


UpperCamelCase__						=			logging.get_logger(__name__)




@dataclass
class   a__			:





						def __init__(							self      :	Union[str, Any]     ,a__      :	List[Any]=False     ,a__      :	Dict=False     ,a__      :	Tuple=6.0     ,a__      :	Any=None     ,a__      :	Union[str, Any]=False     ,a__      :	Tuple=False     ,a__      :	Union[str, Any]=None     ,a__      :	Union[str, Any]="fp4"     ,a__      :	int=False     ,**a__      :	Optional[Any]     ,)						->       Tuple:




											"""simple docstring"""







											_lowerCAmelCase:str									=  load_in_abit
											_lowerCAmelCase:int									=  load_in_abit
											_lowerCAmelCase:str									=  llm_inta_threshold
											_lowerCAmelCase:Tuple									=  llm_inta_skip_modules
											_lowerCAmelCase:List[Any]									=  llm_inta_enable_fpaa_cpu_offload
											_lowerCAmelCase:int									=  llm_inta_has_fpaa_weight
											_lowerCAmelCase:List[str]									=  bnb_abit_quant_type
											_lowerCAmelCase:str									=  bnb_abit_use_double_quant

											if bnb_abit_compute_dtype is None:
																_lowerCAmelCase:List[Any]									=  torch.floataa
											elif isinstance(a__     ,a__):
																_lowerCAmelCase:Optional[Any]									=  getattr(a__     ,a__)
											elif isinstance(a__     ,torch.dtype):
																_lowerCAmelCase:Optional[int]									=  bnb_abit_compute_dtype
											else:
																raise ValueError('''bnb_4bit_compute_dtype must be a string or a torch.dtype''')

											self.post_init()





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




											"""simple docstring"""







											if not isinstance(self.llm_inta_threshold     ,a__):
																raise ValueError('''llm_int8_threshold must be a float''')

											if self.llm_inta_skip_modules is not None and not isinstance(self.llm_inta_skip_modules     ,a__):
																raise ValueError('''llm_int8_skip_modules must be a list of strings''')
											if not isinstance(self.llm_inta_enable_fpaa_cpu_offload     ,a__):
																raise ValueError('''llm_int8_enable_fp32_cpu_offload must be a boolean''')

											if not isinstance(self.llm_inta_has_fpaa_weight     ,a__):
																raise ValueError('''llm_int8_has_fp16_weight must be a boolean''')

											if self.bnb_abit_compute_dtype is not None and not isinstance(self.bnb_abit_compute_dtype     ,torch.dtype):
																raise ValueError('''bnb_4bit_compute_dtype must be torch.dtype''')

											if not isinstance(self.bnb_abit_quant_type     ,a__):
																raise ValueError('''bnb_4bit_quant_type must be a string''')

											if not isinstance(self.bnb_abit_use_double_quant     ,a__):
																raise ValueError('''bnb_4bit_use_double_quant must be a boolean''')

											if self.load_in_abit and not version.parse(importlib.metadata.version('''bitsandbytes''')) >= version.parse(
											    '''0.39.0'''):
																raise ValueError(
																    '''4 bit quantization requires bitsandbytes>=0.39.0 - please upgrade your bitsandbytes version''')





						def       __UpperCamelCase     (							self      :	int)						->       str:




											"""simple docstring"""







											return self.load_in_abit or self.load_in_abit





						def       __UpperCamelCase     (							self      :	Any)						->       List[str]:




											"""simple docstring"""







											if self.load_in_abit:
																return "llm_int8"
											elif self.load_in_abit and self.bnb_abit_quant_type == "fp4":
																return "fp4"
											elif self.load_in_abit and self.bnb_abit_quant_type == "nf4":
																return "nf4"
											else:
																return None





						@classmethod
						def       __UpperCamelCase     (							cls      :	Any     ,a__      :	Optional[int]     ,a__      :	Tuple     ,**a__      :	Any)						->       List[Any]:




											"""simple docstring"""







											_lowerCAmelCase:List[Any]									=  cls(**a__)

											_lowerCAmelCase:List[Any]									=  []
											for key, value in kwargs.items():
																if hasattr(a__     ,a__):
																					setattr(a__     ,a__     ,a__)
																					to_remove.append(a__)
											for key in to_remove:
																kwargs.pop(a__     ,a__)

											if return_unused_kwargs:
																return config, kwargs
											else:
																return config





						def       __UpperCamelCase     (							self      :	Optional[Any]     ,a__      :	Union[str, os.PathLike])						->       Optional[int]:




											"""simple docstring"""







											with open(a__     ,'''w'''     ,encoding='''utf-8''') as writer:
																_lowerCAmelCase:str									=  self.to_dict()
																_lowerCAmelCase:int									=  json.dumps(a__     ,indent=2     ,sort_keys=a__) + '''\n'''

																writer.write(a__)





						def       __UpperCamelCase     (							self      :	int)						->       Dict[str, Any]:




											"""simple docstring"""







											_lowerCAmelCase:Optional[int]									=  copy.deepcopy(self.__dict__)
											_lowerCAmelCase:List[str]									=  str(output['''bnb_4bit_compute_dtype''']).split('''.''')[1]

											return output





						def __repr__(							self      :	int)						->       Any:




											"""simple docstring"""







											return F'{self.__class__.__name__} {self.to_json_string()}'





						def       __UpperCamelCase     (							self      :	Optional[Any]     ,a__      :	bool = True)						->       str:




											"""simple docstring"""







											if use_diff is True:
																_lowerCAmelCase:Optional[int]									=  self.to_diff_dict()
											else:
																_lowerCAmelCase:Optional[int]									=  self.to_dict()
											return json.dumps(a__     ,indent=2     ,sort_keys=a__) + "\n"







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




											"""simple docstring"""







											_lowerCAmelCase:int									=  self.to_dict()

											# get the default config dict
											_lowerCAmelCase:Union[str, Any]									=  BitsAndBytesConfig().to_dict()

											_lowerCAmelCase:Any									=  {}

											# only serialize values that differ from the default config
											for key, value in config_dict.items():
																if value != default_config_dict[key]:
																					_lowerCAmelCase:Tuple									=  value

											return serializable_config_dict












"""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






