code: def main(cfg) -> None:
      logging.info(
          "\n\n************** Experiment configuration ***********"
      )
      logging.info(f"\n{OmegaConf.to_yaml(cfg)}")
  
      # These configs are required to be off during inference.
      def model_cfg_modifier(model_cfg):
          model_cfg.precision = cfg.trainer.precision
          model_cfg.vision.precision = cfg.trainer.precision
          if cfg.trainer.precision != "bf16":
              model_cfg.megatron_amp_O2 = False
          model_cfg.sequence_parallel = False
          model_cfg.activations_checkpoint_granularity = None
          model_cfg.activations_checkpoint_method = None
  
      trainer, model = setup_trainer_and_model_for_inference(
          model_provider=MegatronContentFilteringModel,
          cfg=cfg,
          model_cfg_modifier=model_cfg_modifier,
      )
      image_transform_fn = image_transform(
          (model.cfg.vision.img_h, model.cfg.vision.img_w),
          is_train=False,
          mean=model.cfg.vision.image_mean,
          std=model.cfg.vision.image_std,
          resize_longest_max=True,
      )
  
      autocast_dtype = _get_autocast_dtype(trainer.precision)
      image = Image.open(cfg.image_path).convert("RGB")
      with torch.no_grad(), torch.cuda.amp.autocast(
          enabled=autocast_dtype in (torch.half, torch.bfloat16),
          dtype=autocast_dtype,
      ):
          image = image_transform_fn(image).unsqueeze(0).cuda()
          probability = model(image).sigmoid()
  
      if is_global_rank_zero:
          print(
              "Given image's NSFW probability: ",
              probability.cpu().item(),
          )
  
file_path: NeMo/examples/multimodal/vision_language_foundation/nsfw/megatron_nsfw_infer.py
imports: import torch
  from omegaconf.omegaconf import OmegaConf
  from PIL import Image
  from nemo.collections.multimodal.data.clip.augmentations.augmentations import image_transform
  from nemo.collections.multimodal.models.vision_language_foundation.megatron_nsfw_clip_models import MegatronContentFilteringModel
  from nemo.collections.multimodal.parts.utils import setup_trainer_and_model_for_inference
  from nemo.core.config import hydra_runner
  from nemo.utils import logging
  from nemo.utils.get_rank import is_global_rank_zero
label_desc: Use image node_id 2 for calling a global function with example usage: main(cfg) without return types