import tensorflow as tf

  if not tf.io.gfile.exists(base_dir):
    tf.io.gfile.makedirs(base_dir)
  tag = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
  tb_logdir = osp.join(base_dir, tag, 'tb')
  save_dir = osp.join(base_dir, tag, 'train')
  tf.io.gfile.makedirs(tb_logdir)
  tf.io.gfile.makedirs(save_dir)
  writer = tf.contrib.summary.create_file_writer(tb_logdir)
  writer.set_as_default()
  return writer, save_dir


def record_point_mass_episode(tf_env, tf_policy, savepath=None):
  """Records summaries."""
