code: def restore_state(args):
      session_state_file = os.path.expanduser("~/.clearml_data.json")
      # noinspection PyBroadException
      try:
          with open(session_state_file, "rt") as f:
              state = json.load(f)
      except Exception:
          state = {}
  
      args.id = getattr(args, "id", None) or state.get("id")
  
      state = {
          str(k): str(v) if v is not None else None
          for k, v in args.__dict__.items()
          if not str(k).startswith("_")
      }
      # noinspection PyBroadException
      try:
          with open(session_state_file, "wt") as f:
              json.dump(state, f, sort_keys=True)
      except Exception:
          pass
  
      return args
  
imports: import json
  import os
  import shutil
  from argparse import ArgumentParser, HelpFormatter
  from functools import partial
  from typing import Sequence
  from pathlib2 import Path
  import clearml.backend_api.session
  from clearml.datasets import Dataset
  from clearml.version import __version__
label_desc: Use image node_id 3 for calling a global function with example usage: restore_state(args) and returns: args