code: def get_threshold_preds(
      act, axis, self_threshold=-1, partner_threshold=-1, prettify=True
  ):
      pred = act["text"]
      if prettify:
          pred = pred.split(":")[-1]
  
      if "sorted_scores" in act:
          scores = F.softmax(act["sorted_scores"].float()).tolist()
          scores = [round(x, 4) for x in scores]
          cands = act["text_candidates"]
          if prettify:
              cands = [
                  cand.split(":")[-1].replace(
                      "gender-neutral", "neutral"
                  )
                  for cand in cands
              ]
  
          if axis == "self" and self_threshold > 0:
              if scores[0] > self_threshold:
                  pred = cands[0]
              else:
                  pred = gend_utils.UNKNOWN
          elif axis == "partner" and partner_threshold > 0:
              if cands[0] == "neutral":
                  pred = cands[0]
              else:  # male or female
                  if scores[0] > partner_threshold:
                      pred = cands[0]
                  else:
                      pred = gend_utils.UNKNOWN
  
          if prettify:
              strs = [
                  f"{cand} ({score})"
                  for cand, score in zip(cands, scores)
              ]
              pred += "\n\t" + "[ " + "\t".join(strs) + "]"
  
      return pred
  
file_path: ParlAI/parlai/tasks/md_gender/worlds.py
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from copy import deepcopy
  import torch.nn.functional
  from parlai.core.worlds import DialogPartnerWorld, validate
  import parlai.tasks.md_gender.utils
label_desc: Use image node_id 1 for calling a global function with example usage: get_threshold_preds(act, axis, _threshold, partner_threshold, prettify) and returns: pred