class_docstr: Generic GraphCut optimisation transform.
  
  This can be used in conjuction with any Make*Unaryd transform
  (e.g. MakeISegUnaryd from above for implementing ISeg unary term).
  It optimises a typical energy function for interactive segmentation methods using numpymaxflow's GraphCut method,
  e.g. Equation 5 from https://arxiv.org/pdf/1710.04043.pdf.
  
  Usage Example::
  
      Compose(
          [
              # unary term maker
              MakeISegUnaryd(
                  image="image",
                  logits="logits",
                  scribbles="label",
                  unary="unary",
                  scribbles_bg_label=2,
                  scribbles_fg_label=3,
              ),
              # optimiser
              ApplyGraphCutOptimisationd(
                  unary="unary",
                  pairwise="image",
                  post_proc_label="pred",
                  lamda=10.0,
                  sigma=15.0,
              ),
          ]
      )
class_docstr_tok: ["Generic","GraphCut","optimisation","transform",".","This","can","be","used","in","conjuction","with","any","Make","*","Unaryd","transform","(","e.g",".","MakeISegUnaryd","from","above","for","implementing","ISeg","unary","term",")",".","It","optimises","a","typical","energy","function","for","interactive","segmentation","methods","using","numpymaxflow","'s","GraphCut","method",",","e.g",".","Equation","5","from","https",":","\/\/arxiv.org\/pdf\/1710.04043.pdf",".","Usage","Example",":",":","Compose","(","[","#","unary","term","maker","MakeISegUnaryd","(","image=","''","image","''",",","logits=","''","logits","''",",","scribbles=","''","label","''",",","unary=","''","unary","''",",","scribbles_bg_label=2",",","scribbles_fg_label=3",",",")",",","#","optimiser","ApplyGraphCutOptimisationd","(","unary=","''","unary","''",",","pairwise=","''","image","''",",","post_proc_label=","''","pred","''",",","lamda=10.0",",","sigma=15.0",",",")",",","]",")"]
code: def __init__(
      self,
      unary: str,
      pairwise: str,
      meta_key_postfix: str = "meta_dict",
      post_proc_label: str = "pred",
      lamda: float = 8.0,
      sigma: float = 0.1,
  ) -> None:
      super().__init__(meta_key_postfix)
      self.unary = unary
      self.pairwise = pairwise
      self.post_proc_label = post_proc_label
      self.lamda = lamda
      self.sigma = sigma
  
imports: import logging
  from copy import deepcopy
  from typing import Optional
  import numpy
  import torch
  from monai.data import MetaTensor
  from monai.networks.blocks import CRF
  from monai.transforms import Transform
  from scipy.special import softmax
  from .utils import make_iseg_unary, make_likelihood_image_gmm, make_likelihood_image_histogram, maxflow
label_desc: Use image node_id 1 to create a new ApplyGraphCutOptimisationd object from inherited base classes: InteractiveSegmentationTransform with example: obj = ApplyGraphCutOptimisationd(unary, pairwise, meta_key_postfix, post_proc_label, lamda, sigma)