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(self, output, cands):
      if cands.dim() == 2:
          return torch.matmul(output, cands.t())
      elif cands.dim() == 3:
          return torch.bmm(
              output.unsqueeze(1), cands.transpose(1, 2)
          ).squeeze(1)
      else:
          raise RuntimeError(
              "Unexpected candidate dimensions {}"
              "".format(cands.dim())
          )
  
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 5 for calling the MemnnAgent obj's underlying member method code with example usage: obj._score(output, cands) and returns: torch, torch