docstr: args:
      y_true : 4-d ndarray in [batch_size, chs, img_rows, img_cols]
      y_pred : 4-d ndarray in [batch_size, chs, img_rows, img_cols]
      threshold : [0.0, 1.0]
  return tp/(tp+fp)
docstr_tok: ["args",":","y_true",":","4-d","ndarray","in","[","batch_size",",","chs",",","img_rows",",","img_cols","]","y_pred",":","4-d","ndarray","in","[","batch_size",",","chs",",","img_rows",",","img_cols","]","threshold",":","[","0.0",",","1.0","]","return","tp\/","(","tp+fp",")"]
code: def __call__(self, y_pred, y_true, threshold=0.5):
      """
      args:
          y_true : 4-d ndarray in [batch_size, chs, img_rows, img_cols]
          y_pred : 4-d ndarray in [batch_size, chs, img_rows, img_cols]
          threshold : [0.0, 1.0]
      return tp/(tp+fp)
      """
      batch_size, chs, img_rows, img_cols = y_true.shape
      device = y_true.device
      if chs == 1:
          y_pred = _binarize(y_pred, threshold)
          y_true = _binarize(y_true, threshold)
          nb_tp = _get_tp(y_pred, y_true)
          nb_fp = _get_fp(y_pred, y_true)
          mperforms = nb_tp / (nb_tp + nb_fp + esp)
          performs = None
      else:
          y_pred = _argmax(y_pred, 1)
          y_true = _argmax(y_true, 1)
          performs = torch.zeros(chs, 1).to(device)
          weights = _get_weights(y_true, chs)
          for ch in range(chs):
              y_true_ch = torch.zeros(batch_size, img_rows, img_cols)
              y_pred_ch = torch.zeros(batch_size, img_rows, img_cols)
              y_true_ch[y_true == ch] = 1
              y_pred_ch[y_pred == ch] = 1
              nb_tp = _get_tp(y_pred_ch, y_true_ch)
              nb_fp = _get_fp(y_pred_ch, y_true_ch)
              performs[int(ch)] = nb_tp / (nb_tp + nb_fp + esp)
          mperforms = sum([i * j for (i, j) in zip(performs, weights)])
      return mperforms, performs
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 3 for calling the Precision obj's underlying member method code with example usage: obj.__call__(y_pred, y_true, threshold) and returns: mperforms,  performs