def tokenize_input_sentence(tokenizer, sentence, sentence2, mask_word=-1):
  """Tokenize the input sentence and return tokenized tensors.

  Args:
    tokenizer: The tokenizer to be used for the conversion.
    sentence: The sentence to be tokenized.
    sentence2: The optional second part of the sentence.
    mask_word: Optional index to be replaced with the MASK token.

  Returns:
    tokens: The tokens obtained from the sentence.
  """
  # Set up the sentence structure if it has not been tokenized yet
  if not sentence.startswith(u'[CLS]'):
    sentence = u'[CLS] ' + sentence + u' [SEP]'
    if sentence2:
      sentence = sentence + ' ' + sentence2 + u' [SEP]'
  # Tokenized input
  tokens = tokenizer.tokenize(sentence)
  if mask_word > -1:  # Replace a token with MASK
    tokens[mask_word] = '[MASK]'
  return tokens