class_docstr: Memory decoder.
  
  Given a line of context input, generate a memory to write.
class_docstr_tok: ["Memory","decoder",".","Given","a","line","of","context","input",",","generate","a","memory","to","write","."]
docstr: Generate memories from input.
  
  Each input is split into the lines of conversational context.
  These are considered independently.
  
  We then assign a prefix ("your/partner's persona:") dependent on
  whether the bot or it's partner said the line.
  
  :param input:
      input to the memory decoder
  :param num_inputs:
      number of lines per batch item
docstr_tok: ["Generate","memories","from","input",".","Each","input","is","split","into","the","lines","of","conversational","context",".","These","are","considered","independently",".","We","then","assign","a","prefix","(","``","your\/partner","'s","persona",":","''",")","dependent","on","whether","the","bot","or","it","'s","partner","said","the","line",".",":","param","input",":","input","to","the","memory","decoder",":","param","num_inputs",":","number","of","lines","per","batch","item"]
code: def generate_memories(
      self, input: torch.LongTensor, num_inputs: torch.LongTensor
  ) -> List[List[str]]:
      """
      Generate memories from input.
  
      Each input is split into the lines of conversational context.
      These are considered independently.
  
      We then assign a prefix ("your/partner's persona:") dependent on
      whether the bot or it's partner said the line.
  
      :param input:
          input to the memory decoder
      :param num_inputs:
          number of lines per batch item
      """
      assert self.agent_dict is not None
      memories = []
      for idx, input_i in enumerate(input):
          if num_inputs[idx] == 0:
              continue
          context_lines_vec = input_i[: num_inputs[idx]]
          context_lines = [
              self.agent_dict.vec2txt(self.clean_input(j))
              for j in context_lines_vec
          ]
          raw_memories_i = list(
              reversed(self._batch_generate(context_lines))
          )
          logging.debug(f"raw memories: {raw_memories_i}")
          memories_i = self._extract_from_raw_memories(raw_memories_i)
          logging.debug(f"memories to write: {memories_i}")
          mem_string = "\n".join(memories_i)
          logging.verbose(f"Writing memories: {mem_string}")
          memories.append(memories_i)
  
      self.memories_full_list = memories
      return memories
  
imports: from enum import Enum, auto
  import os
  import string
  import time
  import torch
  import torch.nn
  from typing import List, Tuple, Dict, Optional, Any
  from parlai.agents.rag.retrievers import clean_vec
  from parlai.core.agents import create_agent_from_model_file, create_agent_from_shared
  from parlai.core.build_data import modelzoo_path
  from parlai.core.dict import DictionaryAgent
  from parlai.core.message import Message
  from parlai.core.opt import Opt
  from parlai.core.torch_agent import TorchAgent
  from parlai.tasks.msc.agents import NOPERSONA
  import parlai.utils.logging
label_desc: Use image node_id 2 for calling the MemoryDecoder obj's underlying member method code with example usage: obj.generate_memories(input, num_inputs) and returns: memories