def compute_label_weights_using_sample_size(label_dict, label_sample_size):
  """Compute weights for each class according to their sample sizes.

  Args:
    label_dict: a dictionary with class labels as keys (strings) and encoded
      label index as values (ints).
    label_sample_size: a dictionary with class labels as keys (strings) and
      sample size as values (ints).

  Returns:
    label_weights: weights for labels.
  """

  # keys: encoded class labels, values: sample size
  label_code_sample_size = {
      label_dict[label]: label_sample_size[label]
      for label in label_sample_size.keys()
  }
  print('label_code_sample_size={}'.format(label_code_sample_size))
  # create label weights = 1/label_sample_size
  label_weights = [
      1 / float(label_code_sample_size[idx])
      for idx in range(len(label_code_sample_size))
  ]
  # label_weights = [
  #     x / float(sum(label_weights0)) * len(label_weights0) / float(
  #         params.batch_size) for x in label_weights0
  # ]
  return label_weights