class_docstr: Callback for NNCF compression.
  
  Assumes that the pl module contains a 'model' attribute, which is
  the PyTorch module that must be compressed.
  
  Args:
      config (dict): NNCF Configuration
      export_dir (Str): Path where the export `onnx` and the OpenVINO `xml` and `bin` IR are saved.
                        If None model will not be exported.
class_docstr_tok: ["Callback","for","NNCF","compression",".","Assumes","that","the","pl","module","contains","a","'model","'","attribute",",","which","is","the","PyTorch","module","that","must","be","compressed",".","Args",":","config","(","dict",")",":","NNCF","Configuration","export_dir","(","Str",")",":","Path","where","the","export","`","onnx","`","and","the","OpenVINO","`","xml","`","and","`","bin","`","IR","are","saved",".","If","None","model","will","not","be","exported","."]
docstr: Call when fit or test begins.
  
  Takes the pytorch model and wraps it using the compression controller
  so that it is ready for nncf fine-tuning.
docstr_tok: ["Call","when","fit","or","test","begins",".","Takes","the","pytorch","model","and","wraps","it","using","the","compression","controller","so","that","it","is","ready","for","nncf","fine-tuning","."]
code: def setup(
      self,
      trainer: pl.Trainer,
      pl_module: pl.LightningModule,
      stage: str | None = None,
  ) -> None:
      """Call when fit or test begins.
  
      Takes the pytorch model and wraps it using the compression controller
      so that it is ready for nncf fine-tuning.
      """
      del stage  # `stage` variable is not used.
  
      if self.nncf_ctrl is not None:
          return
  
      # Get validate subset to initialize quantization,
      # because train subset does not contain anomalous images.
      init_loader = InitLoader(trainer.datamodule.val_dataloader())  # type: ignore
      config = register_default_init_args(self.config, init_loader)
  
      self.nncf_ctrl, pl_module.model = wrap_nncf_model(
          model=pl_module.model,
          config=config,
          dataloader=trainer.datamodule.train_dataloader(),  # type: ignore
          init_state_dict=None,  # type: ignore
      )
  
file_path: anomalib/src/anomalib/utils/callbacks/nncf/callback.py
imports: from __future__ import annotations
  import os
  from pathlib import Path
  from typing import Any
  import pytorch_lightning
  from nncf import NNCFConfig
  from nncf.api.compression import CompressionAlgorithmController
  from nncf.torch import register_default_init_args
  from pytorch_lightning import Callback
  from anomalib.utils.callbacks.nncf.utils import InitLoader, wrap_nncf_model
label_desc: Use image node_id 2 for calling the NNCFCallback obj's underlying member method code with example usage: obj.setup(trainer, pl_module, stage) without return types