class_docstr: Nonautoregressive Transformer from https://arxiv.org/abs/1805.11063.
class_docstr_tok: ["Nonautoregressive","Transformer","from","https",":","\/\/arxiv.org\/abs\/1805.11063","."]
docstr: Produce predictions from the model.
docstr_tok: ["Produce","predictions","from","the","model","."]
code: def infer(
      self,
      features=None,
      decode_length=50,
      beam_size=1,
      top_beams=1,
      alpha=0.0,
      use_tpu=False,
  ):
      """Produce predictions from the model."""
      if not features:
          features = {}
      inputs_old = None
      if "inputs" in features and len(features["inputs"].shape) < 4:
          inputs_old = features["inputs"]
          features["inputs"] = tf.expand_dims(features["inputs"], 2)
  
      # Create an initial targets tensor.
      if "partial_targets" in features:
          initial_output = tf.convert_to_tensor(
              features["partial_targets"]
          )
      else:
          batch_size = common_layers.shape_list(features["inputs"])[0]
          length = common_layers.shape_list(features["inputs"])[1]
          target_length = tf.to_int32(2.0 * tf.to_float(length))
          initial_output = tf.zeros(
              (batch_size, target_length, 1, 1), dtype=tf.int64
          )
  
      features["targets"] = initial_output
      logits, _ = self(features)  # pylint: disable=not-callable
      samples = tf.argmax(logits, axis=-1)
      if inputs_old is not None:  # Restore to not confuse Estimator.
          features["inputs"] = inputs_old
      return samples
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  from six.moves import range
  from tensor2tensor.layers import common_layers
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import beam_search
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.python.training import moving_averages
label_desc: Use image node_id 4 for calling the TransformerNAT obj's underlying member method code with example usage: obj.infer(features, decode_length, beam_size, top_beams, alpha, use_tpu) and returns: samples