class_docstr: Clip based content filtering model for NSFW.
class_docstr_tok: ["Clip","based","content","filtering","model","for","NSFW","."]
docstr: Perform model forward pass for given image and factor.
  While inferencing, factors should be equal to default value
docstr_tok: ["Perform","model","forward","pass","for","given","image","and","factor",".","While","inferencing",",","factors","should","be","equal","to","default","value"]
code: def forward(
      self,
      image: torch.Tensor,
      mlp_factor: float = 1.0,
      emb_factor: float = 1.0,
  ) -> torch.Tensor:
      """Perform model forward pass for given image and factor.
      While inferencing, factors should be equal to default value
      """
  
      with torch.no_grad():
          embedding = self.vision_encoder(image).detach()
      cos_similarity = self.cosine_similarity(embedding, self.concepts)
      mlp_similarity = self.mlp_similarity(embedding, self.concepts)
  
      features = torch.cat(
          [
              cos_similarity,
              mlp_similarity * mlp_factor,
              embedding * emb_factor,
          ],
          dim=-1,
      )
  
      return self.nn_classifier(features)
  
imports: import functools
  import itertools
  from typing import List, Optional, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from apex.transformer.pipeline_parallel.utils import get_num_microbatches
  from megatron.core import parallel_state
  from megatron.core.pipeline_parallel.schedules import get_forward_backward_func
  from omegaconf.dictconfig import DictConfig
  from pytorch_lightning.accelerators import CPUAccelerator
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.multimodal.data.clip.clip_dataset import tokenize
  from nemo.collections.multimodal.data.nsfw.nsfw_dataset import build_dataset
  from nemo.collections.multimodal.models.vision_language_foundation.clip.megatron_clip_models import CLIPTextTransformer, CLIPVisionTransformer
  from nemo.collections.nlp.models.language_modeling.megatron_base_model import MegatronBaseModel
  from nemo.collections.nlp.modules.common.megatron.build_model import build_model
  from nemo.collections.nlp.modules.common.megatron.module import Float16Module, MegatronModule
  from nemo.collections.nlp.parts.utils_funcs import get_last_rank, torch_dtype_from_precision
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling the ContentFilteringModel obj's underlying member method code with example usage: obj.forward(image, mlp_factor, emb_factor) and returns: self