class_docstr: A general-purpose logger.
  
  Makes it easy to save diagnostics, hyperparameter configurations, the 
  state of a training run, and the trained model.
docstr: Saves the state of an experiment.
  
  To be clear: this is about saving *state*, not logging diagnostics.
  All diagnostic logging is separate from this function. This function
  will save whatever is in ``state_dict``---usually just a copy of the
  environment---and the most recent parameters for the model you 
  previously set up saving for with ``setup_tf_saver``. 
  
  Call with any frequency you prefer. If you only want to maintain a
  single state and overwrite it at each call with the most recent 
  version, leave ``itr=None``. If you want to keep all of the states you
  save, provide unique (increasing) values for 'itr'.
  
  Args:
      state_dict (dict): Dictionary containing essential elements to
          describe the current state of training.
  
      itr: An int, or None. Current iteration of training.
docstr_tok: ["Saves","the","state","of","an","experiment",".","To","be","clear",":","this","is","about","saving","*","state","*",",","not","logging","diagnostics",".","All","diagnostic","logging","is","separate","from","this","function",".","This","function","will","save","whatever","is","in","``","state_dict","``","--","-usually","just","a","copy","of","the","environment","--","-and","the","most","recent","parameters","for","the","model","you","previously","set","up","saving","for","with","``","setup_tf_saver","``",".","Call","with","any","frequency","you","prefer",".","If","you","only","want","to","maintain","a","single","state","and","overwrite","it","at","each","call","with","the","most","recent","version",",","leave","``","itr=None","``",".","If","you","want","to","keep","all","of","the","states","you","save",",","provide","unique","(","increasing",")","values","for","'itr","'",".","Args",":","state_dict","(","dict",")",":","Dictionary","containing","essential","elements","to","describe","the","current","state","of","training",".","itr",":","An","int",",","or","None",".","Current","iteration","of","training","."]
code: def save_state(self, state_dict, itr=None):
      """
      Saves the state of an experiment.
  
      To be clear: this is about saving *state*, not logging diagnostics.
      All diagnostic logging is separate from this function. This function
      will save whatever is in ``state_dict``---usually just a copy of the
      environment---and the most recent parameters for the model you
      previously set up saving for with ``setup_tf_saver``.
  
      Call with any frequency you prefer. If you only want to maintain a
      single state and overwrite it at each call with the most recent
      version, leave ``itr=None``. If you want to keep all of the states you
      save, provide unique (increasing) values for 'itr'.
  
      Args:
          state_dict (dict): Dictionary containing essential elements to
              describe the current state of training.
  
          itr: An int, or None. Current iteration of training.
      """
      if proc_id() == 0:
          fname = "vars.pkl" if itr is None else "vars%d.pkl" % itr
          try:
              joblib.dump(state_dict, osp.join(self.output_dir, fname))
          except:
              self.log(
                  "Warning: could not pickle state_dict.", color="red"
              )
          if hasattr(self, "tf_saver_elements"):
              self._tf_simple_save(itr)
          if hasattr(self, "pytorch_saver_elements"):
              self._pytorch_simple_save(itr)
  
imports: import json
  import joblib
  import shutil
  import numpy
  import tensorflow
  import torch
  import os.path, time, atexit, os
  import warnings
  from spinup.utils.mpi_tools import proc_id, mpi_statistics_scalar
  from spinup.utils.serialization_utils import convert_json
label_desc: Use image node_id 5 for calling the Logger obj's underlying member method code with example usage: obj.save_state(state_dict, itr) without return types