class_docstr: Basic Inference Task Helper
class_docstr_tok: ["Basic","Inference","Task","Helper"]
docstr: :param path: Model File Path. Supports multiple paths to support versions (Last item will be picked as latest)
  :param network: Model Network (e.g. monai.networks.xyz).  None in case if you use TorchScript (torch.jit).
  :param type: Type of Infer (segmentation, deepgrow etc..)
  :param labels: Labels associated to this Infer
  :param dimension: Input dimension
  :param description: Description
  :param model_state_dict: Key for loading the model state from checkpoint
  :param input_key: Input key for running inference
  :param output_label_key: Output key for storing result/label of inference
  :param output_json_key: Output key for storing result/label of inference
  :param config: K,V pairs to be part of user config
  :param load_strict: Load model in strict mode
  :param roi_size: ROI size for scanning window inference
  :param preload: Preload model/network on all available GPU devices
  :param train_mode: Run in Train mode instead of eval (when network has dropouts)
  :param skip_writer: Skip Writer and return data dictionary
code: def __init__(
      self,
      path: Union[None, str, Sequence[str]],
      network: Union[None, Any],
      type: Union[str, InferType],
      labels: Union[str, None, Sequence[str], Dict[Any, Any]],
      dimension: int,
      description: str,
      model_state_dict: str = "model",
      input_key: str = "image",
      output_label_key: str = "pred",
      output_json_key: str = "result",
      config: Union[None, Dict[str, Any]] = None,
      load_strict: bool = True,
      roi_size=None,
      preload=False,
      train_mode=False,
      skip_writer=False,
  ):
      """
      :param path: Model File Path. Supports multiple paths to support versions (Last item will be picked as latest)
      :param network: Model Network (e.g. monai.networks.xyz).  None in case if you use TorchScript (torch.jit).
      :param type: Type of Infer (segmentation, deepgrow etc..)
      :param labels: Labels associated to this Infer
      :param dimension: Input dimension
      :param description: Description
      :param model_state_dict: Key for loading the model state from checkpoint
      :param input_key: Input key for running inference
      :param output_label_key: Output key for storing result/label of inference
      :param output_json_key: Output key for storing result/label of inference
      :param config: K,V pairs to be part of user config
      :param load_strict: Load model in strict mode
      :param roi_size: ROI size for scanning window inference
      :param preload: Preload model/network on all available GPU devices
      :param train_mode: Run in Train mode instead of eval (when network has dropouts)
      :param skip_writer: Skip Writer and return data dictionary
      """
  
      super().__init__(type, labels, dimension, description, config)
  
      self.path = (
          [] if not path else [path] if isinstance(path, str) else path
      )
      self.network = network
      self.model_state_dict = model_state_dict
      self.input_key = input_key
      self.output_label_key = output_label_key
      self.output_json_key = output_json_key
      self.load_strict = load_strict
      self.roi_size = roi_size
      self.train_mode = train_mode
      self.skip_writer = skip_writer
  
      self._networks: Dict = {}
  
      self._config.update(
          {
              "device": device_list(),
              # "result_extension": None,
              # "result_dtype": None,
              # "result_compress": False
              # "roi_size": self.roi_size,
              # "sw_batch_size": 1,
              # "sw_overlap": 0.25,
          }
      )
  
      if config:
          self._config.update(config)
  
      if preload:
          for device in device_map().values():
              logger.info(f"Preload Network for device: {device}")
              self._get_network(device, None)
  
imports: import copy
  import logging
  import os
  import time
  from abc import abstractmethod
  from enum import Enum
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import torch
  from monai.data import decollate_batch
  from monai.inferers import Inferer, SimpleInferer, SlidingWindowInferer
  from monai.utils import deprecated
  from monailabel.interfaces.exception import MONAILabelError, MONAILabelException
  from monailabel.interfaces.tasks.infer_v2 import InferTask, InferType
  from monailabel.interfaces.utils.transform import dump_data, run_transforms
  from monailabel.transform.cache import CacheTransformDatad
  from monailabel.transform.writer import ClassificationWriter, DetectionWriter, Writer
  from monailabel.utils.others.generic import device_list, device_map, name_to_device
label_desc: Use image node_id 1 to create a new BasicInferTask object from inherited base classes: InferTask with example: obj = BasicInferTask(path, network, type, labels, dimension, description, model_state_dict, input_key, output_label_key, output_json_key, config, load_strict, roi_size, preload, train_mode, skip_writer)