code: def add_negs(
      msg, d, ind, label_type, split, num_cands, use_affordances
  ):
      if label_type == "emote":
          msg["label_candidates"] = cands["emote"]
      if label_type == "which":
          msg["label_candidates"] = cands["which"]
      if label_type == "action":
          if use_affordances:
              msg["label_candidates"] = d["available_actions"][ind]
          else:
              msg["label_candidates"] = d["no_affordance_actions"][ind]
      if label_type == "speech":
          cnt = 0
          label = msg["labels"]
          negs = []
          # negs.append(label)
          used = {}
          # find 99 random negs that are != gold label
          while True:
              ind = rand.randint(0, len(cands["speech"]) - 1)
              txt = cands["speech"][ind]
              if txt != label and ind not in used:
                  negs.append(txt)
                  used[ind] = True
                  cnt += 1
                  if cnt == num_cands - 1:
                      break
          # insert label in a random position
          negs.insert(rand.randrange(len(negs) + 1), label)
          msg["label_candidates"] = negs
  
imports: import random
  import io
  import os
  import json
  from parlai.utils.misc import msg_to_str
label_desc: Use image node_id 7 for calling a global function with example usage: add_negs(msg, d, ind, label_type, split, num_cands, use_affordances) without return types