# tf.contrib.seq2seq.InferenceHelper

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L681-L736) |

A helper to use during inference with a custom sampling function.

Inherits From: [`Helper`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/seq2seq/Helper)

    tf.contrib.seq2seq.InferenceHelper(
        sample_fn, sample_shape, sample_dtype, start_inputs, end_fn, next_inputs_fn=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `sample_fn` | A callable that takes `outputs` and emits tensor `sample_ids`. |
| `sample_shape` | Either a list of integers, or a 1-D Tensor of type `int32`, the shape of the each sample in the batch returned by `sample_fn`. |
| `sample_dtype` | the dtype of the sample returned by `sample_fn`. |
| `start_inputs` | The initial batch of inputs. |
| `end_fn` | A callable that takes `sample_ids` and emits a `bool` vector shaped `[batch_size]` indicating whether each sample is an end token. |
| `next_inputs_fn` | (Optional) A callable that takes `sample_ids` and returns the next batch of inputs. If not provided, `sample_ids` is used as the next batch of inputs. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `batch_size` | Batch size of tensor returned by `sample`. <br /> Returns a scalar int32 tensor. |
| `sample_ids_dtype` | DType of tensor returned by `sample`. <br /> Returns a DType. |
| `sample_ids_shape` | Shape of tensor returned by `sample`, excluding the batch dimension. <br /> Returns a `TensorShape`. |

<br />

## Methods

### `initialize`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L721-L723)

    initialize(
        name=None
    )

Returns `(initial_finished, initial_inputs)`.

### `next_inputs`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L729-L736)

    next_inputs(
        time, outputs, state, sample_ids, name=None
    )

Returns `(finished, next_inputs, next_state)`.

### `sample`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L725-L727)

    sample(
        time, outputs, state, name=None
    )

Returns `sample_ids`.