class_docstr: Abstract class for generators.
class_docstr_tok: ["Abstract","class","for","generators","."]
docstr: Builds the TF graph and loads the checkpoint.
  
  If the graph has already been initialized, this is a no-op.
  
  Raises:
    SequenceGeneratorError: If the checkpoint cannot be found.
docstr_tok: ["Builds","the","TF","graph","and","loads","the","checkpoint",".","If","the","graph","has","already","been","initialized",",","this","is","a","no-op",".","Raises",":","SequenceGeneratorError",":","If","the","checkpoint","can","not","be","found","."]
code: def initialize(self):
      """Builds the TF graph and loads the checkpoint.
  
      If the graph has already been initialized, this is a no-op.
  
      Raises:
        SequenceGeneratorError: If the checkpoint cannot be found.
      """
      if self._initialized:
          return
  
      # Either self._checkpoint or self._bundle should be set.
      # This is enforced by the constructor.
      if self._checkpoint is not None:
          # Check if the checkpoint file exists.
          if not _checkpoint_file_exists(self._checkpoint):
              raise SequenceGeneratorError(
                  "Checkpoint path does not exist: %s"
                  % (self._checkpoint)
              )
          checkpoint_file = self._checkpoint
          # If this is a directory, try to determine the latest checkpoint in it.
          if tf.gfile.IsDirectory(checkpoint_file):
              checkpoint_file = tf.train.latest_checkpoint(
                  checkpoint_file
              )
          if checkpoint_file is None:
              raise SequenceGeneratorError(
                  "No checkpoint file found in directory: %s"
                  % self._checkpoint
              )
          if not _checkpoint_file_exists(
              self._checkpoint
          ) or tf.gfile.IsDirectory(checkpoint_file):
              raise SequenceGeneratorError(
                  "Checkpoint path is not a file: %s (supplied path: %s)"
                  % (checkpoint_file, self._checkpoint)
              )
          self._model.initialize_with_checkpoint(checkpoint_file)
      else:
          # Write checkpoint and metagraph files to a temp dir.
          tempdir = None
          try:
              tempdir = tempfile.mkdtemp()
              checkpoint_filename = os.path.join(tempdir, "model.ckpt")
              with tf.gfile.Open(checkpoint_filename, "wb") as f:
                  # For now, we support only 1 checkpoint file.
                  # If needed, we can later change this to support sharded checkpoints.
                  f.write(self._bundle.checkpoint_file[0])
              metagraph_filename = os.path.join(
                  tempdir, "model.ckpt.meta"
              )
              with tf.gfile.Open(metagraph_filename, "wb") as f:
                  f.write(self._bundle.metagraph_file)
  
              self._model.initialize_with_checkpoint_and_metagraph(
                  checkpoint_filename, metagraph_filename
              )
          finally:
              # Clean up the temp dir.
              if tempdir is not None:
                  tf.gfile.DeleteRecursively(tempdir)
      self._initialized = True
  
imports: import abc
  import os
  import tempfile
  from note_seq.protobuf import generator_pb2
  import tensorflow.compat.v1
label_desc: Use image node_id 5 for calling the BaseSequenceGenerator obj's underlying member method code with example usage: obj.initialize() without return types