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","."]
code: def __init__(self, opt: Opt):
      self.opt = opt
      self.agents = []
      self.agent_dict = None
      self.generations = []
      self.input_type = "Memory"
      self.delimiter = opt.get("memory_decoder_delimiter", "\n")
      self.one_line_memories = opt.get(
          "memory_decoder_one_line_memories", False
      )
      model_file = modelzoo_path(
          opt["datapath"], opt["memory_decoder_model_file"]
      )
      if model_file and os.path.exists(model_file):
          logging.info(
              f"Building Memory Decoder from file: {model_file}"
          )
          logging.disable()
          overrides = {
              "skip_generation": False,
              "inference": "beam",
              "beam_size": opt.get("memory_decoder_beam_size", 3),
              "beam_min_length": opt.get(
                  "memory_decoder_beam_min_length", 10
              ),
              "beam_block_ngram": 3,
              "no_cuda": opt.get("no_cuda", False),
          }
          if self.opt.get("memory_decoder_truncate", -1) > 0:
              overrides["text_truncate"] = self.opt[
                  "memory_decoder_truncate"
              ]
              overrides["truncate"] = self.opt[
                  "memory_decoder_truncate"
              ]
          base_agent = create_agent_from_model_file(
              model_file, opt_overrides=overrides
          )
          assert isinstance(base_agent, TorchAgent)
          self.agents = [base_agent]
          assert isinstance(self.agents[0], TorchAgent)
          copies = max(
              100, (opt["batchsize"] * opt.get("rag_turn_n_turns", 1))
          )
          self.agents += [
              create_agent_from_shared(self.agents[0].share())
              for _ in range(copies)
          ]
          self.agent_dict = self.agents[0].build_dictionary()
          logging.enable()
  
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 1 to create a new MemoryDecoder object from inherited base classes: BB2SubmoduleMixin with example: obj = MemoryDecoder(opt)