docstr: Return whether the memory is valid.
  
  It rejects new memory entry as invalid if one similar to it exists already.
docstr_tok: ["Return","whether","the","memory","is","valid",".","It","rejects","new","memory","entry","as","invalid","if","one","similar","to","it","exists","already","."]
code: def is_valid_memory(
      cls,
      chatbot_memory: Union[List[str], Dict[str, int]],
      new_memory: str,
      new_memory_prefix: str,
  ) -> bool:
      """
      Return whether the memory is valid.
  
      It rejects new memory entry as invalid if one similar to it exists already.
      """
      if new_memory in (
          CONST.NOPERSONA,
          PROMPT.NO_MEMORY,
          "",
          APIUtils.METASEQ_FAIL_MESSAGE_TEXT,
      ):
          return False
  
      # Rejecting if identical memories exist already.
      if not chatbot_memory:
          # No need to dedup if there is no existing memory
          return True
  
      # filtering for the memories that applies to the current person (self or other)
      person_memories = [
          MemoryUtils.split_prefix_memory(mem)[1]
          for mem in chatbot_memory
          if MemoryUtils.split_prefix_memory(mem)[0]
          == new_memory_prefix
      ]
      if not person_memories:
          # No memory on record for this person
          return True
  
      return no_overlap(person_memories, new_memory)
  
imports: import aiohttp
  import asyncio
  from enum import Enum
  import json
  import math
  from nltk.corpus import stopwords
  from nltk.tokenize import word_tokenize
  from nltk.stem import PorterStemmer
  import os
  import random
  import string
  import time
  from typing import List, Tuple, Optional, Dict, Any, Set, Union
  from parlai.agents.ir_baseline.ir_baseline import score_match, MaxPriorityQueue
  from parlai.core.dict import DictionaryAgent
  from parlai.core.message import Message
  from parlai.core.metrics import F1Metric
  from parlai.core.torch_generator_agent import PPLMetric
  import parlai.utils.logging
  import projects.bb3.constants
  import projects.bb3.prompts
  from projects.bb3.agents.module import Module
label_desc: Use image node_id 6 for calling the MemoryUtils obj's underlying member method code with example usage: obj.is_valid_memory(cls, chatbot_memory, new_memory, new_memory_prefix) and returns: no_overlap, False, True, True