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 run_scoring(self, image_id, simulation_size, model_ts, datastore):
      start = time.time()
      request = {
          "image": datastore.get_image_uri(image_id),
          "logging": "error",
          "cache_transforms": False,
      }
  
      accum_unl_outputs = []
      for i in range(simulation_size):
          data = self.infer_task(request=request)
          pred = (
              data[self.infer_task.output_label_key]
              if isinstance(data, dict)
              else None
          )
          if pred is not None:
              logger.debug(
                  f"EPISTEMIC:: {image_id} => {i} => pred: {pred.shape}; sum: {np.sum(pred)}"
              )
              accum_unl_outputs.append(pred)
          else:
              logger.info(
                  f"EPISTEMIC:: {image_id} => {i} => pred: None"
              )
  
      accum = torch.stack(accum_unl_outputs)
      accum = torch.squeeze(accum)
  
      # Accum Expected shape for 2D images is (N, C, H, W) for 3D (N, C, H, W, D)
      # To handle cases where only a single class of segmentation is present, an extra dimension is added
      if self.dimension == 2 and len(accum.shape) == 3:
          accum = torch.unsqueeze(accum, dim=1)
      elif self.dimension == 3 and len(accum.shape) == 4:
          accum = torch.unsqueeze(accum, dim=1)
  
      entropy = (
          self.variance_volume(accum)
          if self.use_variance
          else self.entropy_volume(accum)
      )
      entropy = float(np.nanmean(entropy))
  
      latency = time.time() - start
      logger.info(
          "EPISTEMIC:: {} => iters: {}; entropy: {}; latency: {};".format(
              image_id,
              simulation_size,
              round(entropy, 4),
              round(latency, 3),
          )
      )
  
      # Add epistemic_entropy in datastore
      info = {
          self.key_output_entropy: entropy,
          self.key_output_ts: model_ts,
      }
      datastore.update_image_info(image_id, info)
  
file_path: MONAILabel/monailabel/tasks/scoring/epistemic_v2.py
imports: import logging
  import multiprocessing
  import os
  import time
  from concurrent.futures import ThreadPoolExecutor
  import numpy
  import torch
  from monai.metrics.active_learning_metrics import VarianceMetric
  from monailabel.interfaces.datastore import Datastore
  from monailabel.interfaces.tasks.scoring import ScoringMethod
  from monailabel.tasks.infer.basic_infer import BasicInferTask
  from monailabel.utils.others.generic import name_to_device
label_desc: Use image node_id 5 for calling the EpistemicScoring obj's underlying member method code with example usage: obj.run_scoring(image_id, simulation_size, model_ts, datastore) without return types