class_docstr: An implementation of a rendering backend in Blender/Cycles.
class_docstr_tok: ["An","implementation","of","a","rendering","backend","in","Blender\/Cycles","."]
docstr: Saves the '.blend' blender file to disk.
  
  If a file with the same path exists, it is overwritten.
docstr_tok: ["Saves","the","'.blend","'","blender","file","to","disk",".","If","a","file","with","the","same","path","exists",",","it","is","overwritten","."]
code: def save_state(self, path: PathLike, pack_textures: bool = True):
      """Saves the '.blend' blender file to disk.
  
      If a file with the same path exists, it is overwritten.
      """
      # first write to a temporary file, and later copy
      # (because blender cannot write to gcs buckets etc.)
      tmp_path = self.scratch_dir / "scene.blend"
      # ensure file does NOT exist (as otherwise "scene.blend1" is created instead of "scene.blend")
      kb.as_path(tmp_path).unlink(missing_ok=True)
  
      # --- ensure directory exists
      parent = kb.as_path(tmp_path).parent
      if not parent.exists():
          parent.mkdir(parents=True)
  
      # --- save the file; see https://github.com/google-research/kubric/issues/96
      with RedirectStream(stream=sys.stdout, disabled=self.verbose):
          with io.StringIO() as fstdout:  # < scratch stdout buffer
              with redirect_stdout(
                  fstdout
              ):  # < also suppresses python stdout
                  if pack_textures:
                      bpy.ops.file.pack_all()
                  bpy.ops.wm.save_mainfile(filepath=str(tmp_path))
              if self.verbose:
                  print(fstdout.getvalue())
  
      # copy to target path
      path = kb.as_path(path)
      path.parent.mkdir(
          parents=True, exist_ok=True
      )  # ensure directory exists
      logger.info("Saving '%s'", path)
      tf.io.gfile.copy(tmp_path, path, overwrite=True)
  
imports: import collections
  import io
  import logging
  import os
  import sys
  from contextlib import redirect_stdout
  from typing import Any, Dict, Optional, Sequence, Union
  import tempfile
  from kubric.safeimport.bpy import bpy
  import numpy
  import tensorflow
  from singledispatchmethod import singledispatchmethod
  import kubric
  from kubric import core
  from kubric.core.assets import UndefinedAsset
  from kubric.redirect_io import RedirectStream
  from kubric.renderer import blender_utils
  from kubric import file_io
  from kubric.file_io import PathLike
label_desc: Use image node_id 15 for calling the Blender obj's underlying member method code with example usage: obj.save_state(path, pack_textures) without return types