def _get_attention_weights(cell, is_training):
  """ Obtain the attention weights if needed. """
  weights = None
  if is_training:
    weights = cell._cells[-1]._cell.attention_weights  # pylint: disable=W0212
  else:
    weights = cell._cells[-1].attention_weights  # pylint: disable=W0212
  return weights