def find_input_index(index, input_ranges):
  """Find the input index given the index of training data."""
  return next(i for i, input in enumerate(input_ranges)
              if input['start'] <= index < input['end'])