def get_tag_group(tag):
  """Gets the group id from tag string.

  For example, tag string of <S> is 0, <S1> is 1.
  Assumes single digit group id.

  Args:
    tag: Tag string

  Returns:
    group_id: Return extracted group id
  """

  group_id = 0 if len(tag) <= 3 else int(tag[-2])
  return group_id