


import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel






class      UpperCamelCase(	_a ):
					snake_case_		:					Tuple    					=						"""M-CLIP"""


					def __init__(    self						:		List[str]  ,     SCREAMING_SNAKE_CASE						:		Union[str, Any]=1_0_2_4  ,     SCREAMING_SNAKE_CASE						:		List[Any]=7_6_8  ,     **SCREAMING_SNAKE_CASE						:		Any    )      ->						Union[str, Any]:




											'''simple docstring'''

											__snake_case				=		transformerDimSize
											__snake_case				=		imageDimSize
											super().__init__(**SCREAMING_SNAKE_CASE    )






class      UpperCamelCase(	_a ):
					snake_case_		:					List[str]    					=						MCLIPConfig


					def __init__(    self						:		str  ,     SCREAMING_SNAKE_CASE						:		List[str]  ,     *SCREAMING_SNAKE_CASE						:		List[Any]  ,     **SCREAMING_SNAKE_CASE						:		int    )      ->						List[str]:




											'''simple docstring'''

											super().__init__(SCREAMING_SNAKE_CASE  ,     *SCREAMING_SNAKE_CASE  ,     **SCREAMING_SNAKE_CASE    )
											__snake_case				=		XLMRobertaModel(SCREAMING_SNAKE_CASE    )
											__snake_case				=		torch.nn.Linear(
											    in_features=config.transformerDimensions  ,     out_features=config.numDims    )






					def 				SCREAMING_SNAKE_CASE_	(    self						:		Any  ,     SCREAMING_SNAKE_CASE						:		Optional[Any]  ,     SCREAMING_SNAKE_CASE						:		str    )      ->						str:




											'''simple docstring'''

											__snake_case				=		self.transformer(input_ids=SCREAMING_SNAKE_CASE  ,     attention_mask=SCREAMING_SNAKE_CASE    )[0]
											__snake_case				=		(embs * attention_mask.unsqueeze(2    )).sum(dim=1    ) / attention_mask.sum(dim=1    )[:, None]
											return self.LinearTransformation(SCREAMING_SNAKE_CASE    ), embs









import inspect
import unittest






class      UpperCamelCase(	unittest.TestCase ):


					def 				SCREAMING_SNAKE_CASE_	(    self						:		Dict    )      ->						List[Any]:




											'''simple docstring'''

											try:
																	import diffusers  # noqa: F401
											except ImportError:
																	assert False






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




											'''simple docstring'''

											import diffusers
											from diffusers.dependency_versions_table import deps

											__snake_case				=		inspect.getmembers(SCREAMING_SNAKE_CASE  ,     inspect.isclass    )

											for cls_name, cls_module in all_classes:
																	if "dummy_" in cls_module.__module__:
																							for backend in cls_module._backends:
																													if backend == "k_diffusion":
																																			__snake_case				=		"k-diffusion"
																													elif backend == "invisible_watermark":
																																			__snake_case				=		"invisible-watermark"
																													assert backend in deps, f'''{backend} is not in the deps table!'''





