
'''simple docstring'''



from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
     import tensorflow as tf

     from transformers import (
         TFFunnelBaseModel,
         TFFunnelForMaskedLM,
         TFFunnelForMultipleChoice,
         TFFunnelForPreTraining,
         TFFunnelForQuestionAnswering,
         TFFunnelForSequenceClassification,
         TFFunnelForTokenClassification,
         TFFunnelModel,
     )

class  _a					:





       """simple docstring"""




       def __init__(				self							,				A__							,				A__=13							,				A__=7							,				A__=True							,				A__=True							,				A__=True							,				A__=True							,				A__=99							,				A__=[1, 1, 2]							,				A__=1							,				A__=32							,				A__=4							,				A__=8							,				A__=37							,				A__="gelu_new"							,				A__=0.1							,				A__=0.1							,				A__=0.0							,				A__=5_12							,				A__=3							,				A__=0.02							,				A__=3							,				A__=4							,				A__=None							,				A__=False							,				)     ->      List[Any]:
          _SCREAMING_SNAKE_CASE  			=					parent
          _SCREAMING_SNAKE_CASE  			=					batch_size
          _SCREAMING_SNAKE_CASE  			=					seq_length
          _SCREAMING_SNAKE_CASE  			=					is_training
          _SCREAMING_SNAKE_CASE  			=					use_input_mask
          _SCREAMING_SNAKE_CASE  			=					use_token_type_ids
          _SCREAMING_SNAKE_CASE  			=					use_labels
          _SCREAMING_SNAKE_CASE  			=					vocab_size
          _SCREAMING_SNAKE_CASE  			=					block_sizes
          _SCREAMING_SNAKE_CASE  			=					num_decoder_layers
          _SCREAMING_SNAKE_CASE  			=					d_model
          _SCREAMING_SNAKE_CASE  			=					n_head
          _SCREAMING_SNAKE_CASE  			=					d_head
          _SCREAMING_SNAKE_CASE  			=					d_inner
          _SCREAMING_SNAKE_CASE  			=					hidden_act
          _SCREAMING_SNAKE_CASE  			=					hidden_dropout
          _SCREAMING_SNAKE_CASE  			=					attention_dropout
          _SCREAMING_SNAKE_CASE  			=					activation_dropout
          _SCREAMING_SNAKE_CASE  			=					max_position_embeddings
          _SCREAMING_SNAKE_CASE  			=					type_vocab_size
          _SCREAMING_SNAKE_CASE  			=					2
          _SCREAMING_SNAKE_CASE  			=					num_labels
          _SCREAMING_SNAKE_CASE  			=					num_choices
          _SCREAMING_SNAKE_CASE  			=					scope
          _SCREAMING_SNAKE_CASE  			=					initializer_std

          # Used in the tests to check the size of the first attention layer
          _SCREAMING_SNAKE_CASE  			=					n_head
          # Used in the tests to check the size of the first hidden state
          _SCREAMING_SNAKE_CASE  			=					self.d_model
          # Used in the tests to check the number of output hidden states/attentions
          _SCREAMING_SNAKE_CASE  			=					sum(self.block_sizes   ) + (0 if base else self.num_decoder_layers)
          # FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
          # the last hidden state of the first block (which is the first hidden state of the decoder).
          if not base:
             _SCREAMING_SNAKE_CASE  			=					self.num_hidden_layers + 2






       def 							UpperCamelCase					(				self   )     ->      Optional[int]:
          _SCREAMING_SNAKE_CASE  			=					ids_tensor([self.batch_size, self.seq_length]							,				self.vocab_size   )

          _SCREAMING_SNAKE_CASE  			=					None
          if self.use_input_mask:
             _SCREAMING_SNAKE_CASE  			=					random_attention_mask([self.batch_size, self.seq_length]   )

          _SCREAMING_SNAKE_CASE  			=					None
          if self.use_token_type_ids:
             _SCREAMING_SNAKE_CASE  			=					ids_tensor([self.batch_size, self.seq_length]							,				self.type_vocab_size   )

          _SCREAMING_SNAKE_CASE  			=					None
          _SCREAMING_SNAKE_CASE  			=					None
          _SCREAMING_SNAKE_CASE  			=					None
          if self.use_labels:
             _SCREAMING_SNAKE_CASE  			=					ids_tensor([self.batch_size]							,				self.type_sequence_label_size   )
             _SCREAMING_SNAKE_CASE  			=					ids_tensor([self.batch_size, self.seq_length]							,				self.num_labels   )
             _SCREAMING_SNAKE_CASE  			=					ids_tensor([self.batch_size]							,				self.num_choices   )

          _SCREAMING_SNAKE_CASE  			=					FunnelConfig(
              vocab_size=self.vocab_size							,				block_sizes=self.block_sizes							,				num_decoder_layers=self.num_decoder_layers							,				d_model=self.d_model							,				n_head=self.n_head							,				d_head=self.d_head							,				d_inner=self.d_inner							,				hidden_act=self.hidden_act							,				hidden_dropout=self.hidden_dropout							,				attention_dropout=self.attention_dropout							,				activation_dropout=self.activation_dropout							,				max_position_embeddings=self.max_position_embeddings							,				type_vocab_size=self.type_vocab_size							,				initializer_std=self.initializer_std							,				)

          return (
              config,
              input_ids,
              token_type_ids,
              input_mask,
              sequence_labels,
              token_labels,
              choice_labels,
          )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      List[str]:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelModel(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )

          _SCREAMING_SNAKE_CASE  			=					[input_ids, input_mask]
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )

          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, self.seq_length, self.d_model)   )

          _SCREAMING_SNAKE_CASE  			=					False
          _SCREAMING_SNAKE_CASE  			=					TFFunnelModel(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, self.seq_length, self.d_model)   )

          _SCREAMING_SNAKE_CASE  			=					False
          _SCREAMING_SNAKE_CASE  			=					TFFunnelModel(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, self.seq_length, self.d_model)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      List[Any]:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelBaseModel(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )

          _SCREAMING_SNAKE_CASE  			=					[input_ids, input_mask]
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )

          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, 2, self.d_model)   )

          _SCREAMING_SNAKE_CASE  			=					False
          _SCREAMING_SNAKE_CASE  			=					TFFunnelBaseModel(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, 3, self.d_model)   )

          _SCREAMING_SNAKE_CASE  			=					False
          _SCREAMING_SNAKE_CASE  			=					TFFunnelBaseModel(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, 2, self.d_model)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      List[Any]:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelForPreTraining(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.seq_length)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      Optional[Any]:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelForMaskedLM(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.seq_length, self.vocab_size)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      Any:
          _SCREAMING_SNAKE_CASE  			=					self.num_labels
          _SCREAMING_SNAKE_CASE  			=					TFFunnelForSequenceClassification(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.num_labels)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      Any:
          _SCREAMING_SNAKE_CASE  			=					self.num_choices
          _SCREAMING_SNAKE_CASE  			=					TFFunnelForMultipleChoice(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					tf.tile(tf.expand_dims(lowerCAmelCase__							,				1   )							,				(1, self.num_choices, 1)   )
          _SCREAMING_SNAKE_CASE  			=					tf.tile(tf.expand_dims(lowerCAmelCase__							,				1   )							,				(1, self.num_choices, 1)   )
          _SCREAMING_SNAKE_CASE  			=					tf.tile(tf.expand_dims(lowerCAmelCase__							,				1   )							,				(1, self.num_choices, 1)   )
          _SCREAMING_SNAKE_CASE  			=					{
              '''input_ids''': multiple_choice_inputs_ids,
              '''attention_mask''': multiple_choice_input_mask,
              '''token_type_ids''': multiple_choice_token_type_ids,
          }
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.num_choices)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      Optional[int]:
          _SCREAMING_SNAKE_CASE  			=					self.num_labels
          _SCREAMING_SNAKE_CASE  			=					TFFunnelForTokenClassification(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.seq_length, self.num_labels)   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				A__							,				)     ->      Dict:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelForQuestionAnswering(config=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
          _SCREAMING_SNAKE_CASE  			=					model(lowerCAmelCase__   )
          self.parent.assertEqual(result.start_logits.shape							,				(self.batch_size, self.seq_length)   )
          self.parent.assertEqual(result.end_logits.shape							,				(self.batch_size, self.seq_length)   )






       def 							UpperCamelCase					(				self   )     ->      Any:
          _SCREAMING_SNAKE_CASE  			=					self.prepare_config_and_inputs()
          (
              _SCREAMING_SNAKE_CASE
          )  			=					config_and_inputs
          _SCREAMING_SNAKE_CASE  			=					{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
          return config, inputs_dict






@require_tf
class  _a					(snake_case_	,       snake_case_	,       unittest.TestCase):





       """simple docstring"""




       SCREAMING_SNAKE_CASE   =	(
           (
               TFFunnelModel,
               TFFunnelForMaskedLM,
               TFFunnelForPreTraining,
               TFFunnelForQuestionAnswering,
               TFFunnelForTokenClassification,
           )
           if is_tf_available()
           else ()
       )
       SCREAMING_SNAKE_CASE   =	(
           {
               'feature-extraction': (TFFunnelBaseModel, TFFunnelModel),
               'fill-mask': TFFunnelForMaskedLM,
               'question-answering': TFFunnelForQuestionAnswering,
               'text-classification': TFFunnelForSequenceClassification,
               'token-classification': TFFunnelForTokenClassification,
               'zero-shot': TFFunnelForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )
       SCREAMING_SNAKE_CASE   =	False
       SCREAMING_SNAKE_CASE   =	False






       def 							UpperCamelCase					(				self   )     ->      Optional[Any]:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelModelTester(self   )
          _SCREAMING_SNAKE_CASE  			=					ConfigTester(self							,				config_class=lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      int:
          self.config_tester.run_common_tests()






       def 							UpperCamelCase					(				self   )     ->      Any:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      List[str]:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_pretraining(*lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      List[str]:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      Optional[int]:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      int:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase__   )






@require_tf
class  _a					(snake_case_	,       unittest.TestCase):





       """simple docstring"""




       SCREAMING_SNAKE_CASE   =	(
           (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
       )
       SCREAMING_SNAKE_CASE   =	False
       SCREAMING_SNAKE_CASE   =	False






       def 							UpperCamelCase					(				self   )     ->      List[str]:
          _SCREAMING_SNAKE_CASE  			=					TFFunnelModelTester(self							,				base=lowerCAmelCase__   )
          _SCREAMING_SNAKE_CASE  			=					ConfigTester(self							,				config_class=lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      Tuple:
          self.config_tester.run_common_tests()






       def 							UpperCamelCase					(				self   )     ->      List[Any]:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_base_model(*lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      List[Any]:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase__   )






       def 							UpperCamelCase					(				self   )     ->      List[str]:
          _SCREAMING_SNAKE_CASE  			=					self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_multiple_choice(*lowerCAmelCase__   )











'''simple docstring'''



import torch
import torch.nn as nn
from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel

from ...utils import logging


lowerCAmelCase_  :							int             =    logging.get_logger(__name__)
def        UpperCAmelCase (    A	:					List[Any]       ,		A	:					Optional[int]					):
							SCREAMING_SNAKE_CASE       :   Any         =      nn.functional.normalize(A					)
							SCREAMING_SNAKE_CASE       :   List[str]         =      nn.functional.normalize(A					)
							return torch.mm(A       ,		normalized_text_embeds.t()					)






class 						lowerCamelCase_				(       snake_case_      ):
						_lowerCAmelCase  : Optional[Any]						  =					CLIPConfig

						_lowerCAmelCase  : List[str]						  =					['CLIPEncoderLayer']







						def __init__(	self :   int					,     lowerCAmelCase__ :   CLIPConfig					):

													"""simple docstring"""
													super().__init__(lowerCAmelCase__					)

													SCREAMING_SNAKE_CASE       :   Any         =      CLIPVisionModel(config.vision_config					)
													SCREAMING_SNAKE_CASE       :   List[str]         =      nn.Linear(config.vision_config.hidden_size					,     config.projection_dim					,     bias=lowerCAmelCase__					)

													SCREAMING_SNAKE_CASE       :   Any         =      nn.Parameter(torch.ones(17					,     config.projection_dim					)					,     requires_grad=lowerCAmelCase__					)
													SCREAMING_SNAKE_CASE       :   int         =      nn.Parameter(torch.ones(3					,     config.projection_dim					)					,     requires_grad=lowerCAmelCase__					)

													SCREAMING_SNAKE_CASE       :   Dict         =      nn.Parameter(torch.ones(17					)					,     requires_grad=lowerCAmelCase__					)
													SCREAMING_SNAKE_CASE       :   List[str]         =      nn.Parameter(torch.ones(3					)					,     requires_grad=lowerCAmelCase__					)







						@torch.no_grad()
						def        __lowercase     (	self :   List[str]					,     lowerCAmelCase__ :   List[str]					,     lowerCAmelCase__ :   Optional[Any]					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Any         =      self.vision_model(lowerCAmelCase__					)[1]  # pooled_output
													SCREAMING_SNAKE_CASE       :   Any         =      self.visual_projection(lowerCAmelCase__					)

													# we always cast to float32 as this does not cause significant overhead and is compatible with bfloat16
													SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      cosine_distance(lowerCAmelCase__					,     self.special_care_embeds					).cpu().float().numpy()
													SCREAMING_SNAKE_CASE       :   List[str]         =      cosine_distance(lowerCAmelCase__					,     self.concept_embeds					).cpu().float().numpy()

													SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      []
													SCREAMING_SNAKE_CASE       :   int         =      image_embeds.shape[0]
													for i in range(lowerCAmelCase__					):
																				SCREAMING_SNAKE_CASE       :   Any         =      {'''special_scores''': {}, '''special_care''': [], '''concept_scores''': {}, '''bad_concepts''': []}

																				# increase this value to create a stronger `nfsw` filter
																				# at the cost of increasing the possibility of filtering benign images
																				SCREAMING_SNAKE_CASE       :   int         =      0.0

																				for concept_idx in range(len(special_cos_dist[0]					)					):
																											SCREAMING_SNAKE_CASE       :   Optional[int]         =      special_cos_dist[i][concept_idx]
																											SCREAMING_SNAKE_CASE       :   int         =      self.special_care_embeds_weights[concept_idx].item()
																											SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      round(concept_cos - concept_threshold + adjustment					,     3					)
																											if result_img["special_scores"][concept_idx] > 0:
																																		result_img["special_care"].append({concept_idx, result_img['''special_scores'''][concept_idx]}					)
																																		SCREAMING_SNAKE_CASE       :   Tuple         =      0.01

																				for concept_idx in range(len(cos_dist[0]					)					):
																											SCREAMING_SNAKE_CASE       :   Optional[Any]         =      cos_dist[i][concept_idx]
																											SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      self.concept_embeds_weights[concept_idx].item()
																											SCREAMING_SNAKE_CASE       :   Dict         =      round(concept_cos - concept_threshold + adjustment					,     3					)
																											if result_img["concept_scores"][concept_idx] > 0:
																																		result_img["bad_concepts"].append(lowerCAmelCase__					)

																				result.append(lowerCAmelCase__					)

													SCREAMING_SNAKE_CASE       :   Dict         =      [len(res['''bad_concepts''']					) > 0 for res in result]

													return images, has_nsfw_concepts







						@torch.no_grad()
						def        __lowercase     (	self :   List[str]					,     lowerCAmelCase__ :   torch.FloatTensor					,     lowerCAmelCase__ :   torch.FloatTensor					):

													"""simple docstring"""
													SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      self.vision_model(lowerCAmelCase__					)[1]  # pooled_output
													SCREAMING_SNAKE_CASE       :   List[Any]         =      self.visual_projection(lowerCAmelCase__					)

													SCREAMING_SNAKE_CASE       :   List[str]         =      cosine_distance(lowerCAmelCase__					,     self.special_care_embeds					)
													SCREAMING_SNAKE_CASE       :   List[str]         =      cosine_distance(lowerCAmelCase__					,     self.concept_embeds					)

													# increase this value to create a stronger `nsfw` filter
													# at the cost of increasing the possibility of filtering benign images
													SCREAMING_SNAKE_CASE       :   Optional[int]         =      0.0

													SCREAMING_SNAKE_CASE       :   Any         =      special_cos_dist - self.special_care_embeds_weights + adjustment
													# special_scores = special_scores.round(decimals=3)
													SCREAMING_SNAKE_CASE       :   List[Any]         =      torch.any(special_scores > 0					,     dim=1					)
													SCREAMING_SNAKE_CASE       :   Dict         =      special_care * 0.01
													SCREAMING_SNAKE_CASE       :   List[str]         =      special_adjustment.unsqueeze(1					).expand(-1					,     cos_dist.shape[1]					)

													SCREAMING_SNAKE_CASE       :   Optional[int]         =      (cos_dist - self.concept_embeds_weights) + special_adjustment
													# concept_scores = concept_scores.round(decimals=3)
													SCREAMING_SNAKE_CASE       :   Any         =      torch.any(concept_scores > 0					,     dim=1					)

													return images, has_nsfw_concepts




