





import numpy as np
import torch
import torch.nn as nn
from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel

from ...utils import logging


__lowerCAmelCase :Union[str, Any]     =    logging.get_logger(__name__)






class        _a(    __A    ):
		lowerCamelCase__     :Dict   				=		CLIPConfig

		lowerCamelCase__     :Union[str, Any]   				=		['CLIPEncoderLayer']







		def __init__(    self ,						__snake_case				)      ->      Union[str, Any]:


							'''simple docstring'''

							super().__init__(__snake_case				)

							_snake_case       :					List[Any]				       =   CLIPVisionModelWithProjection(config.vision_config				)

							_snake_case       :					Union[str, Any]				       =   nn.Linear(config.vision_config.projection_dim ,						1				)
							_snake_case       :					List[Any]				       =   nn.Linear(config.vision_config.projection_dim ,						1				)







		@torch.no_grad()
		def        lowercase       (    self ,						__snake_case ,						__snake_case ,						__snake_case=0.5 ,						__snake_case=0.5				)      ->      Optional[Any]:


							'''simple docstring'''

							_snake_case       :					List[Any]				       =   self.vision_model(__snake_case				)[0]

							_snake_case       :					List[str]				       =   self.p_head(__snake_case				)
							_snake_case       :					Optional[Any]				       =   nsfw_detected.flatten()
							_snake_case       :					Dict				       =   nsfw_detected > p_threshold
							_snake_case       :					int				       =   nsfw_detected.tolist()

							if any(__snake_case				):
												logger.warning(
												    "Potential NSFW content was detected in one or more images. A black image will be returned instead."
												    " Try again with a different prompt and/or seed."				)

							for idx, nsfw_detected_ in enumerate(__snake_case				):
												if nsfw_detected_:
																	_snake_case       :					Optional[Any]				       =   np.zeros(images[idx].shape				)

							_snake_case       :					int				       =   self.w_head(__snake_case				)
							_snake_case       :					Dict				       =   watermark_detected.flatten()
							_snake_case       :					List[Any]				       =   watermark_detected > w_threshold
							_snake_case       :					Optional[int]				       =   watermark_detected.tolist()

							if any(__snake_case				):
												logger.warning(
												    "Potential watermarked content was detected in one or more images. A black image will be returned instead."
												    " Try again with a different prompt and/or seed."				)

							for idx, watermark_detected_ in enumerate(__snake_case				):
												if watermark_detected_:
																	_snake_case       :					Optional[int]				       =   np.zeros(images[idx].shape				)

							return images, nsfw_detected, watermark_detected






import re







def    A				(							UpperCAmelCase				):
					_snake_case       :					Any				       =   re.compile(R"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$"				)
					if match := re.search(UpperCAmelCase  ,  UpperCAmelCase				):
										return match.string == phone
					return False


if __name__ == "__main__":
							print(indian_phone_validator('+918827897895'))