class_docstr: Uses shared variable names when persisting to zip file.
  
  If a shared variable has a name, this name is used as the name of the
  NPY file inside of the zip file. NumPy arrays that aren't matched to a
  shared variable are persisted as usual (i.e. `array_0`, `array_1`,
  etc.)
  
  :param allow_unnamed: Allow shared variables without a name to be
      persisted. Defaults to ``True``.
  :type allow_unnamed: bool, optional
  
  :param allow_duplicates: Allow multiple shared variables to have the same
      name, in which case they will be numbered e.g. `x`, `x_2`, `x_3`, etc.
      Defaults to ``True``.
  :type allow_duplicates: bool, optional
  
  :raises ValueError
      If an unnamed shared variable is encountered and `allow_unnamed` is
      ``False``, or if two shared variables have the same name, and
      `allow_duplicates` is ``False``.
class_docstr_tok: ["Uses","shared","variable","names","when","persisting","to","zip","file",".","If","a","shared","variable","has","a","name",",","this","name","is","used","as","the","name","of","the","NPY","file","inside","of","the","zip","file",".","NumPy","arrays","that","are","n't","matched","to","a","shared","variable","are","persisted","as","usual","(","i.e",".","`","array_0","`",",","`","array_1","`",",","etc",".",")",":","param","allow_unnamed",":","Allow","shared","variables","without","a","name","to","be","persisted",".","Defaults","to","``","True","``",".",":","type","allow_unnamed",":","bool",",","optional",":","param","allow_duplicates",":","Allow","multiple","shared","variables","to","have","the","same","name",",","in","which","case","they","will","be","numbered","e.g",".","`","x","`",",","`","x_2","`",",","`","x_3","`",",","etc",".","Defaults","to","``","True","``",".",":","type","allow_duplicates",":","bool",",","optional",":","raises","ValueError","If","an","unnamed","shared","variable","is","encountered","and","`","allow_unnamed","`","is","``","False","``",",","or","if","two","shared","variables","have","the","same","name",",","and","`","allow_duplicates","`","is","``","False","``","."]
code: def __init__(
      self, zip_file, allow_unnamed=True, allow_duplicates=True
  ):
      super().__init__(zip_file)
      self.name_counter = defaultdict(int)
      self.ndarray_names = {}
      self.allow_unnamed = allow_unnamed
      self.allow_duplicates = allow_duplicates
  
imports: import os
  import pickle
  import sys
  import tempfile
  import zipfile
  from collections import defaultdict
  from contextlib import closing
  from io import BytesIO
  from pickle import HIGHEST_PROTOCOL
  import numpy
  import pytensor
  from pytensor.compile.sharedvalue import SharedVariable
label_desc: Use image node_id 1 to create a new PersistentSharedVariableID object from inherited base classes: PersistentNdarrayID with example: obj = PersistentSharedVariableID(zip_file, allow_unnamed, allow_duplicates)