class_docstr: Dataset scheduling for multiple text-to-text problems.
class_docstr_tok: ["Dataset","scheduling","for","multiple","text-to-text","problems","."]
docstr: Assumes that example contains both inputs and targets.
docstr_tok: ["Assumes","that","example","contains","both","inputs","and","targets","."]
code: def normalize_example(self, example, hparams):
      """Assumes that example contains both inputs and targets."""
  
      length = self.max_length(hparams)
  
      def _to_constant_shape(tensor):
          tensor = tensor[:length]
          tensor = tf.pad(tensor, [(0, length - tf.shape(tensor)[0])])
          return tf.reshape(tensor, [length])
  
      if self.has_inputs:
          example["inputs"] = _to_constant_shape(example["inputs"])
          example["targets"] = _to_constant_shape(example["targets"])
      elif "inputs" in example:
          if self.packed_length:
              raise ValueError(
                  "cannot concatenate packed examples on the fly."
              )
          inputs = example.pop("inputs")[:-1]  # Remove EOS token.
          targets = tf.concat([inputs, example["targets"]], 0)
          example["targets"] = _to_constant_shape(targets)
      else:
          example["targets"] = _to_constant_shape(example["targets"])
      if self.packed_length:
          if self.has_inputs:
              if "inputs_segmentation" in example:
                  example["inputs_segmentation"] = _to_constant_shape(
                      example["inputs_segmentation"]
                  )
                  example["inputs_position"] = _to_constant_shape(
                      example["inputs_position"]
                  )
              else:
                  example["inputs_segmentation"] = tf.to_int64(
                      tf.not_equal(example["inputs"], 0)
                  )
                  example["inputs_position"] = example[
                      "inputs_segmentation"
                  ] * tf.range(length, dtype=tf.int64)
          if "targets_segmentation" in example:
              example["targets_segmentation"] = _to_constant_shape(
                  example["targets_segmentation"]
              )
              example["targets_position"] = _to_constant_shape(
                  example["targets_position"]
              )
          else:
              example["targets_segmentation"] = tf.to_int64(
                  tf.not_equal(example["targets"], 0)
              )
              example["targets_position"] = example[
                  "targets_segmentation"
              ] * tf.range(length, dtype=tf.int64)
      return example
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import os
  import numpy
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import text_problems
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling the MultiText2TextProblem obj's underlying member method code with example usage: obj.normalize_example(example, hparams) and returns: example, tf