message: Use ShouldUsePaddedIO() as a helper func
diff: @@ -944,6 +944,18 @@ void RestoreParams(const OpInputList params_input,
  }
  }
  +bool ShouldUsePaddedIO(const Tensor* sequence_lengths, bool time_major) {
  + auto seq_array = sequence_lengths->template flat<int>().data();
  + bool all_max_seq_length = true;
  + for (int i = 0; i < model_shapes.batch_size; i++) {
  + if (seq_array[i] != model_shapes.max_seq_length) {
  + all_max_seq_length = false;
  + break;
  + }
  + }
  + return !(time_major && all_max_seq_length);
  +}
  +
  } // namespace
  // Note: all following kernels depend on a RnnDescriptor instance, which
  @@ -1862,15 +1874,7 @@ class CudnnRNNBackwardOp<GPUDevice, T> : public CudnnRNNKernelCommon {
  context, model_types(), time_major, &input,
  &input_h, &input_c, &params,
  &sequence_lengths, num_proj, &model_shapes));
  - auto seq_array = sequence_lengths->template flat<int>().data();
  - bool all_max_seq_length = true;
  - for (int i = 0; i < model_shapes.batch_size; i++) {
  - if (seq_array[i] != model_shapes.max_seq_length) {
  - all_max_seq_length = false;
  - break;
  - }
  - }
  - use_padded_io = !(time_major && all_max_seq_length);
  + use_padded_io = ShouldUsePaddedIO(sequence_lengths, time_major);
  } else {
  OP_REQUIRES_OK(context,
  ExtractForwardInput(context, model_types(), time_major,
  