class_docstr: First version of Epistemic computation used as active learning strategy
class_docstr_tok: ["First","version","of","Epistemic","computation","used","as","active","learning","strategy"]
code: def __call__(self, request, datastore: Datastore):
      logger.info("Starting Epistemic Uncertainty scoring")
  
      result = {}
      model, model_ts = self._load_model(self.model, self.network)
      if not model:
          return
      model = model.to(self.device).train()
  
      # Performing Epistemic for all unlabeled images
      skipped = 0
      unlabeled_images = datastore.get_unlabeled_images()
      num_samples = request.get("num_samples", self.num_samples)
      if num_samples < 2:
          num_samples = 2
          logger.warning(
              "EPISTEMIC:: Fixing 'num_samples=2' as min 2 samples are needed to compute entropy"
          )
  
      logger.info(
          f"EPISTEMIC:: Total unlabeled images: {len(unlabeled_images)}"
      )
      for image_id in unlabeled_images:
          image_info = datastore.get_image_info(image_id)
          prev_ts = image_info.get("epistemic_ts", 0)
          if prev_ts == model_ts:
              skipped += 1
              continue
  
          logger.info(
              f"EPISTEMIC:: Run for image: {image_id}; Prev Ts: {prev_ts}; New Ts: {model_ts}"
          )
  
          # Computing the Entropy
          start = time.time()
          data = {"image": datastore.get_image_uri(image_id)}
          accum_unl_outputs = []
          for i in range(num_samples):
              output_pred = self.infer_seg(
                  data, model, self.roi_size, 1
              )
              logger.info(
                  f"EPISTEMIC:: {image_id} => {i} => pred: {output_pred.shape}; sum: {np.sum(output_pred)}"
              )
              accum_unl_outputs.append(output_pred)
  
          accum_numpy = np.stack(accum_unl_outputs)
          accum_numpy = np.squeeze(accum_numpy)
          accum_numpy = (
              accum_numpy[:, 1:, :, :, :]
              if len(accum_numpy.shape) > 4
              else accum_numpy
          )
  
          entropy = float(
              np.nanmean(self.entropy_3d_volume(accum_numpy))
          )
  
          if self.device == "cuda":
              torch.cuda.empty_cache()
          latency = time.time() - start
  
          logger.info(f"EPISTEMIC:: {image_id} => entropy: {entropy}")
          logger.info(
              f"EPISTEMIC:: Time taken for {num_samples} Monte Carlo Simulation samples: {latency}"
          )
  
          # Add epistemic_entropy in datastore
          info = {
              "epistemic_entropy": entropy,
              "epistemic_ts": model_ts,
          }
          datastore.update_image_info(image_id, info)
          result[image_id] = info
  
      logger.info(
          f"EPISTEMIC:: Total: {len(unlabeled_images)}; Skipped = {skipped}; Executed: {len(result)}"
      )
      return result
  
file_path: MONAILabel/monailabel/tasks/scoring/epistemic.py
imports: import copy
  import logging
  import os
  import time
  import numpy
  import torch
  from monai.inferers import sliding_window_inference
  from monai.transforms import Compose
  from monai.utils import deprecated
  from monailabel.interfaces.datastore import Datastore
  from monailabel.interfaces.tasks.scoring import ScoringMethod
label_desc: Use image node_id 6 for calling the EpistemicScoring obj's underlying member method code with example usage: obj.__call__(request, datastore) and returns: result