class_docstr: OPT BB3 Agent.
class_docstr_tok: ["OPT","BB3","Agent","."]
docstr: Get the opening memories, if applicable.
  
  This function is designed to handle legacy cases where memories are
  presented as a list, rather than a dict.
  
  :param memories:
      memories from the opening message
  
  :return opening_memories:
      return the set of true opening memories
docstr_tok: ["Get","the","opening","memories",",","if","applicable",".","This","function","is","designed","to","handle","legacy","cases","where","memories","are","presented","as","a","list",",","rather","than","a","dict",".",":","param","memories",":","memories","from","the","opening","message",":","return","opening_memories",":","return","the","set","of","true","opening","memories"]
code: def get_opening_memories(
      self, memories: Optional[Union[List[str], Dict[str, int]]]
  ) -> Optional[Dict[str, int]]:
      """
      Get the opening memories, if applicable.
  
      This function is designed to handle legacy cases where memories are
      presented as a list, rather than a dict.
  
      :param memories:
          memories from the opening message
  
      :return opening_memories:
          return the set of true opening memories
      """
      opening_memories = None
      if memories:
          if isinstance(memories, dict):
              opening_memories = {
                  mem: int(turns) for mem, turns in memories.items()
              }
          elif isinstance(memories, list):
              opening_memories = {}
              for mem in memories:
                  opening_memories = self.memory_utils.add_memory(
                      mem, opening_memories
                  )
  
      assert not opening_memories or isinstance(opening_memories, dict)
      return opening_memories
  
imports: import copy
  import random
  from typing import List, Optional, Dict, Any, Union, Tuple
  from parlai.agents.rag.retrievers import Document
  from parlai.core.agents import Agent, create_agent
  from parlai.core.message import Message
  from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  import parlai.utils.logging
  from projects.bb3.agents.module import Module
  from projects.bb3.agents.r2c2_bb3_agent import BlenderBot3Agent
  from projects.bb3.agents.opt_api_agent import BB3OPTAgent
  from projects.bb3.agents.search_agent import SearchAgent
  from projects.bb3.agents.utils import Decision, APIUtils, is_opener, DisplayUtils, set_failed_reply
  import projects.bb3.prompts
label_desc: Use image node_id 11 for calling the BlenderBot3Agent obj's underlying member method code with example usage: obj.get_opening_memories(memories) and returns: opening_memories