def load_db_checkpoint(var_name,
                       checkpoint_dir,
                       dtype = tf.float32,
                       cpu = True,
                       trainable = False,
                       is_local_variable = True):
  """Load weights for variables from checkpoint.

  Args:
    var_name: variable name
    checkpoint_dir: checkpoint dir
    dtype: data type
    cpu: if load to cpu or not
    trainable: train loaded variable or not
    is_local_variable: local or global variable

  Returns:
    variables loaded with weights from checkpoint
  """
  shape = get_var_shape(checkpoint_dir, var_name)
  get_variable_func = (
      tf.get_local_variable if is_local_variable else tf.get_variable)

  if cpu:
    with tf.device('/cpu:0'):
      tf_db = get_variable_func(
          var_name,
          shape=shape,
          dtype=dtype,
          trainable=trainable,
          use_resource=True)
  else:
    tf_db = get_variable_func(
        var_name,
        shape=shape,
        dtype=dtype,
        trainable=trainable,
        use_resource=True)

  assignment_map = {var_name: tf_db}
  tf.train.init_from_checkpoint(checkpoint_dir, assignment_map)

  return tf_db
Load weights for variables from checkpoint.

  Args:
    var_name: variable name
    checkpoint_dir: checkpoint dir
    dtype: data type
    cpu: if load to cpu or not
    trainable: train loaded variable or not
    is_local_variable: local or global variable

  Returns:
    variables loaded with weights from checkpoint
  
language/emql/util.py