class_docstr: Memory Network agent.
  
  Tips:
  - time features are necessary when memory order matters
  - multiple hops allow multiple steps of reasoning, but also seem to make it
      easier to learn to read the memories if you have at least two hops
  - 'adam' seems to work very poorly compared to 'sgd' for hogwild training
class_docstr_tok: ["Memory","Network","agent",".","Tips",":","-","time","features","are","necessary","when","memory","order","matters","-","multiple","hops","allow","multiple","steps","of","reasoning",",","but","also","seem","to","make","it","easier","to","learn","to","read","the","memories","if","you","have","at","least","two","hops","-","'adam","'","seems","to","work","very","poorly","compared","to","'sgd","'","for","hogwild","training"]
code: def score_candidates(self, batch, cand_vecs, cand_encs=None):
      mems = self._build_mems(batch.memory_vecs)
      # Check for rows that have no non-null tokens
      pad_mask = None
      if mems is not None:
          pad_mask = (mems != self.NULL_IDX).sum(dim=-1) == 0
  
      if cand_encs is not None:
          state, _ = self.model(batch.text_vec, mems, None, pad_mask)
      else:
          state, cand_encs = self.model(
              batch.text_vec, mems, cand_vecs, pad_mask
          )
      scores = self._score(state, cand_encs)
  
      return scores
  
imports: from typing import Optional
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from functools import lru_cache
  import torch
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from .modules import MemNN, opt_to_kwargs
label_desc: Use image node_id 7 for calling the MemnnAgent obj's underlying member method code with example usage: obj.score_candidates(batch, cand_vecs, cand_encs) and returns: scores