class_docstr: Override TorchRankerAgent to include label in fixed cands set.
  
  Necessary for certain IR tasks where given candidate set does not contain example
  labels.
class_docstr_tok: ["Override","TorchRankerAgent","to","include","label","in","fixed","cands","set",".","Necessary","for","certain","IR","tasks","where","given","candidate","set","does","not","contain","example","labels","."]
code: def _build_candidates(self, batch, source, mode):
      cands, cand_vecs, label_inds = super()._build_candidates(
          batch, source, mode
      )
      label_vecs = batch.label_vec  # [bsz] list of lists of LongTensors
      batchsize = (
          batch.text_vec.size(0)
          if batch.text_vec is not None
          else batch.image.size(0)
      )
  
      if (
          source == "fixed"
          and label_inds is None
          and self.add_label_to_fixed_cands
      ):
          # Add label to fixed cands
          if label_vecs is not None:
              label_inds = label_vecs.new_empty((batchsize))
              for batch_idx, label_vec in enumerate(label_vecs):
                  max_c_len = cand_vecs.size(1)
                  label_vec_pad = label_vec.new_zeros(max_c_len).fill_(
                      self.NULL_IDX
                  )
                  if max_c_len < len(label_vec):
                      label_vec = label_vec[0:max_c_len]
                  label_vec_pad[0 : label_vec.size(0)] = label_vec
                  label_inds[batch_idx] = self._find_match(
                      cand_vecs, label_vec_pad
                  )
                  if label_inds[batch_idx] == -1:
                      cand_vecs = torch.cat(
                          (cand_vecs, label_vec_pad.unsqueeze(0))
                      )
                      cands.append(batch.labels[batch_idx])
                      label_inds[batch_idx] = len(cands) - 1
  
      return (cands, cand_vecs, label_inds)
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import torch
  from .transformer import TransformerRankerAgent
  from parlai.core.torch_ranker_agent import TorchRankerAgent
label_desc: Use image node_id 3 for calling the AddLabelFixedCandsTRA obj's underlying member method code with example usage: obj._build_candidates(batch, source, mode) and returns: cands,  cand_vecs,  label_inds