code: def read_pred_file(
      path, file_format=None, format_fn=None, ignore_header=False
  ):
      f = open(path, "r", encoding="utf-8")
      if ignore_header:
          f.readline()
      preds = []
      confs = []
      if file_format is None and format_fn is None:
          file_format = "pred_and_softmax"
      if file_format == "pred_only":
          format_fn = lambda x: (x, 1)
      elif file_format == "binary_conf":
  
          def formatz(x):
              conf = float(x)
              confs = np.array([1 - conf, conf])
              pred = int(np.argmax(confs))
              return pred, confs
  
          format_fn = formatz
      elif file_format == "softmax":
  
          def formatz(x):
              confs = np.array([float(y) for y in x.split()])
              pred = int(np.argmax(confs))
              return pred, confs
  
          format_fn = formatz
      elif file_format == "pred_and_conf":
  
          def formatz(x):
              pred, conf = x.split()
              if pred.isdigit():
                  pred = int(pred)
              return pred, float(conf)
  
          format_fn = formatz
      elif file_format == "pred_and_softmax":
  
          def formatz(x):
              allz = x.split()
              pred = allz[0]
              confs = np.array([float(x) for x in allz[1:]])
              if pred.isdigit():
                  pred = int(pred)
              return pred, confs
  
          format_fn = formatz
      elif file_format is None:
          pass
      else:
          raise (
              Exception(
                  "file_format %s not suported. Accepted values are pred_only, softmax, binary_conf, pred_and_conf, pred_and_softmax"
                  % file_format
              )
          )
      for l in f:
          l = l.strip("\n")
          p, c = format_fn(l)
          preds.append(p)
          confs.append(c)
      if file_format == "pred_only" and all(
          [x.isdigit() for x in preds]
      ):
          preds = [int(x) for x in preds]
      return preds, confs
  
imports: from abc import ABC, abstractmethod
  import dill
  from munch import Munch
  import numpy
  import inspect
  from .expect import iter_with_optional, Expect
  from .viewer.test_summarizer import TestSummarizer
label_desc: Use image node_id 2 for calling a global function with example usage: read_pred_file(path, file_format, format_fn, ignore_header) and returns: preds,  confs, pred,  confs, pred,  confs, pred,  float, pred,  confs