def pad_items(items, pad_id):
  """
  `items`: a list of lists (each row has different number of elements).

  Return:
    padded_items: a converted items where shorter rows are padded by pad_id.
    lengths: lengths of rows in original items.
  """
  lengths = [len(row) for row in items]
  max_l = max(lengths)
  for i in range(len(items)):
    items[i] = items[i] + ([pad_id] * (max_l - len(items[i])))
  return items, lengths