code: def normalize_example(self, example, hparams):
      
  
      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
docs: Assumes that example contains both inputs and targets.