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 __call__(self, data):
      d = dict(data)
  
      # attempt to fetch algorithmic parameters from app if present
      self.lamda = d.get("lamda", self.lamda)
      self.sigma = d.get("sigma", self.sigma)
  
      # copy affine meta data from pairwise input
      self._copy_affine(d, self.pairwise, self.post_proc_label)
  
      # read relevant terms from data
      unary_term = self._fetch_data(d, self.unary)
      pairwise_term = self._fetch_data(d, self.pairwise)
  
      # check if input unary is compatible with GraphCut opt
      if unary_term.shape[0] > 2:
          raise ValueError(
              f"GraphCut can only be applied to binary probabilities, received {unary_term.shape[0]}"
          )
  
      # attempt to unfold probability term
      # unary_term = self._unfold_prob(unary_term, axis=0)
  
      # prepare data for numpymaxflow's GraphCut
      # run GraphCut
      post_proc_label = maxflow(
          pairwise_term, unary_term, lamda=self.lamda, sigma=self.sigma
      )
  
      d = self._save_data(d, self.post_proc_label, post_proc_label)
  
      return d
  
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 2 for calling the ApplyGraphCutOptimisationd obj's underlying member method code with example usage: obj.__call__(data) and returns: d