import collections


def create_features(inp_sequence):
  """Create a feature vector composed of unary and pairwise counts."""
  # count[1:4] represents the single token counts
  # Example: count[I] = #I in `inp_sequence`
  # count[5:20] represents the pairwise token counts
  # Example: count[4*I + J] = #IJ  in `inp_sequence`
  counts = collections.defaultdict(int)
  prev = str(inp_sequence[0])
  counts[prev] = 1
  for val in map(str, inp_sequence[1:]):
    counts[val] += 1
    counts[prev + val] += 1
    prev = val
  return counts