code: def compute_or_load_data(path, compute_data_fn):
      """Computes or loads data."""
      if tf.gfile.Exists(path):
          logging.info("Load data from %s", path)
          with tf.gfile.Open(path, "rb") as f:
              result = np.load(f)
              return result
  
      result = compute_data_fn()
  
      logging.info("Save data to %s", path)
      bytes_io = io.BytesIO()
      np.savez(bytes_io, **result)
      with tf.gfile.Open(path, "wb") as f:
          f.write(bytes_io.getvalue())
      return result
  
file_path: magenta/magenta/models/gansynth/lib/util.py
imports: import io
  import os
  from absl import logging
  import numpy
  import tensorflow.compat.v1
  import tf_slim
label_desc: Use image node_id 5 for calling a global function with example usage: compute_or_load_data(path, compute_data_fn) and returns: result, result