code: def initialize(self):
      assert self.is_initialized is None
      self.is_initialized = False
  
      with self:
          if self.summarizer is not None:
              directory = self.summarizer["directory"]
              if os.path.isdir(directory):
                  directories = sorted(
                      d
                      for d in os.listdir(directory)
                      if os.path.isdir(os.path.join(directory, d))
                      and d.startswith("summary-")
                  )
              else:
                  os.makedirs(directory)
                  directories = list()
  
              filename = self.summarizer.get("filename")
              if filename is None:
                  filename = time.strftime("summary-%Y%m%d-%H%M%S")
  
                  max_summaries = self.summarizer.get("max_summaries")
                  if max_summaries is None:
                      max_summaries = 7
                  if len(directories) > max_summaries - 1:
                      for subdir in directories[
                          : len(directories) - max_summaries + 1
                      ]:
                          subdir = os.path.join(directory, subdir)
                          os.remove(
                              os.path.join(
                                  subdir, os.listdir(subdir)[0]
                              )
                          )
                          os.rmdir(subdir)
  
              logdir = os.path.join(directory, filename)
              flush_millis = self.summarizer.get("flush")
              if flush_millis is None:
                  flush_millis = 10000
              else:
                  flush_millis *= 1000
              # with tf.name_scope(name='summarizer'):
              self.summarizer = tf.summary.create_file_writer(
                  logdir=logdir,
                  max_queue=None,
                  flush_millis=flush_millis,
                  filename_suffix=None,
                  name="summarizer",
              )
  
              # TODO: write agent spec?
              # tf.summary.text(name, data, step=None, description=None)
  
          super().initialize()
  
          self.core_initialize()
  
          # Units, used in: Parameter, Model.save(), Model.summarizer????
          self.units = dict(
              timesteps=self.timesteps,
              episodes=self.episodes,
              updates=self.updates,
          )
  
          # Checkpoint manager
          if self.saver is not None:
              self.saver_directory = self.saver["directory"]
              self.saver_filename = self.saver.get("filename")
              if self.saver_filename is None:
                  self.saver_filename = self.name
              load = self.saver.get("load", False)
              max_checkpoints = self.saver.get("max_checkpoints")
              if max_checkpoints is None:
                  max_checkpoints = 10
              unit = self.saver.get("unit")
              if unit is None:
                  unit = "updates"
              frequency = self.saver.get("frequency")
              if frequency is None:
                  frequency = 10
              # with tf.name_scope(name='saver'):
              self.checkpoint = tf.train.Checkpoint(**{self.name: self})
              self.saver = tf.train.CheckpointManager(
                  checkpoint=self.checkpoint,
                  directory=self.saver_directory,
                  max_to_keep=max_checkpoints,
                  keep_checkpoint_every_n_hours=self.saver.get(
                      "max_hour_frequency"
                  ),
                  checkpoint_name=self.saver_filename,
                  step_counter=self.units[unit],
                  checkpoint_interval=frequency,
                  init_fn=None,
              )
  
      self.is_initialized = True
  
      if self.summarizer is None:
          self.initialize_api()
      else:
          with self.summarizer.as_default():
              self.initialize_api()
  
      if self.saver is not None:
          if load:
              self.restore()
          else:
              self.save()
  
imports: from collections import OrderedDict
  import logging
  import os
  import time
  import h5py
  import numpy
  import tensorflow
  from tensorforce import TensorforceError
  from tensorforce.core import ArrayDict, Module, SignatureDict, TensorDict, TensorSpec, TensorsSpec, tf_function, tf_util, VariableDict
  from tensorforce.core.layers import Layer
label_desc: Use image node_id 9 for calling the Model obj's underlying member method code with example usage: obj.initialize() without return types