class_docstr: Abstract TorchRankerAgent class; only meant to be extended.
  
  TorchRankerAgents aim to provide convenient functionality for building ranking
  models. This includes:
  
  - Training/evaluating on candidates from a variety of sources.
  - Computing hits@1, hits@5, mean reciprical rank (MRR), and other metrics.
  - Caching representations for fast runtime when deploying models to production.
class_docstr_tok: ["Abstract","TorchRankerAgent","class",";","only","meant","to","be","extended",".","TorchRankerAgents","aim","to","provide","convenient","functionality","for","building","ranking","models",".","This","includes",":","-","Training\/evaluating","on","candidates","from","a","variety","of","sources",".","-","Computing","hits","@","1",",","hits","@","5",",","mean","reciprical","rank","(","MRR",")",",","and","other","metrics",".","-","Caching","representations","for","fast","runtime","when","deploying","models","to","production","."]
docstr: Given a batch and candidate set, return scores (for ranking).
  
  :param Batch batch:
      a Batch object (defined in torch_agent.py)
  :param LongTensor cand_vecs:
      padded and tokenized candidates
  :param FloatTensor cand_encs:
      encoded candidates, if these are passed into the function (in cases
      where we cache the candidate encodings), you do not need to call
      self.model on cand_vecs
docstr_tok: ["Given","a","batch","and","candidate","set",",","return","scores","(","for","ranking",")",".",":","param","Batch","batch",":","a","Batch","object","(","defined","in","torch_agent.py",")",":","param","LongTensor","cand_vecs",":","padded","and","tokenized","candidates",":","param","FloatTensor","cand_encs",":","encoded","candidates",",","if","these","are","passed","into","the","function","(","in","cases","where","we","cache","the","candidate","encodings",")",",","you","do","not","need","to","call","self.model","on","cand_vecs"]
code: def score_candidates(self, batch, cand_vecs, cand_encs=None):
      """
      Given a batch and candidate set, return scores (for ranking).
  
      :param Batch batch:
          a Batch object (defined in torch_agent.py)
      :param LongTensor cand_vecs:
          padded and tokenized candidates
      :param FloatTensor cand_encs:
          encoded candidates, if these are passed into the function (in cases
          where we cache the candidate encodings), you do not need to call
          self.model on cand_vecs
      """
      pass
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from typing import Dict, Any
  from abc import abstractmethod
  from itertools import islice
  import os
  from tqdm import tqdm
  import random
  import torch
  from parlai.core.opt import Opt
  from parlai.utils.distributed import is_distributed
  from parlai.core.torch_agent import TorchAgent, Output
  from parlai.utils.misc import warn_once
  from parlai.utils.io import PathManager
  from parlai.utils.torch import padded_3d, total_parameters, trainable_parameters, PipelineHelper
  from parlai.utils.fp16 import FP16SafeCrossEntropy
  from parlai.core.metrics import AverageMetric
  import parlai.utils.logging
label_desc: Use image node_id 7 for calling the TorchRankerAgent obj's underlying member method code with example usage: obj.score_candidates(batch, cand_vecs, cand_encs) without return types