@tf_export('PeriodicResample')
def periodic_resample(values, shape, name=None):
    'Periodically resample elements of a tensor to conform to `shape`.\n\n  This function implements a slightly more generic version of the subpixel\n  convolutions found in this [paper](https://arxiv.org/abs/1609.05158).\n\n  The formula for computing the elements in the `output` tensor is as follows:\n    `T` = `values` tensor of rank `R`\n    `S` = desired `shape` of output tensor (vector of length `R`)\n    `P` = `output` tensor of rank `R`\n    \\((T_1,\\ldots,T_R)\\) = shape(`T`)\n    \\([S_1,\\ldots,S_q,\\ldots,S_R]\\) = elements of vector `S`\n\n    A single element in `S` is left unspecified (denoted \\(S_q=-1\\)).\n    Let \\(f_i\\) denote the (possibly non-integer) factor that relates the original\n    dimension to the desired dimensions, \\(S_i=f_i T_i\\), for \\(i\\neq q\\) where\n    \\(f_i>0\\).\n    Define the following:\n      \\(g_i=\\lceil f_i\\rceil\\)\n      \\(t=\\prod_i T_i\\)\n      \\(s=\\prod_{i\\neq q} S_i\\)\n    \\(S_q\\) can then be defined as by \\(S_q=\\lfloor t/s\\rfloor\\).\n    The elements of the resulting tensor are defined as\n    \\(P_{s_1,\\ldots,s_R}=T_{h_1,\\ldots,h_q,\\ldots,h_R}\\).\n    The \\(h_i\\) (\\(i\\neq q\\)) are defined by \\(h_i=\\lfloor s_i/g_i\\rfloor\\).\n    \\(h_q=S_q\\sum_{j\\neq q}^{q-1}G_j \\mathrm{mod}(s_j,g_j) + s_q\\), where\n    \\(G_j=\\prod_{i}^{j-1}g_i\\) (\\(G_0=1\\)).\n\n  One drawback of this method is that whenever the output dimensions are slightly\n  less than integer multiples of the input dimensions, many of the tensor elements\n  are repeated in an inefficient way. This is resolved by specifying that all\n  desired dimensions are integer multiples of the input tensor.\n\n  For example:\n\n  ```prettyprint\n  `input` is [[ 0  1  2  3]\n              [ 4  5  6  7]\n              [ 8  9 10 11]]\n\n  tf.periodic_resample(input, [6, None]) ==> [[ 0  1]\n                                              [ 2  3]\n                                              [ 4  5]\n                                              [ 6  7]\n                                              [ 8  9]\n                                              [10 11]]\n  ```\n\n  Args:\n    values: A `Tensor`. Must be one of the following types: `float32`, `float64`, `int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`, `complex128`, `qint8`, `quint8`, `qint32`, `half`, `uint32`, `uint64`, `bfloat16`.\n      The tensor of rank `R` to periodic_resample\n    shape: A `tf.TensorShape` or list of `ints`.\n      A 1-D tensor representing the desired shape of the output tensor.\n      Exactly one element of this tensor must have the value `None` which represents\n      that this dimension of `values` can be adjusted downward in order to\n      accommodate increases in other dimensions. The specified sizes of the\n      non-adjustable dimensions must by at least as large as in the `values` tensor.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `Tensor`. Has the same type as `values`.\n    Periodically resampled tensor that has dimensions specified as in\n    `shape` except that the dimension specified as `None` will be minimally\n    decreased as necessary.\n  '
    shape = _execute.make_shape(shape, 'shape')
    _ctx = _context.context()
    if _ctx.in_graph_mode():
        (_, _, _op) = _op_def_lib._apply_op_helper('PeriodicResample', values=values, shape=shape, name=name)
        _result = _op.outputs[:]
        _inputs_flat = _op.inputs
        _attrs = ('T', _op.get_attr('T'), 'shape', _op.get_attr('shape'))
    else:
        (_attr_T, (values,)) = _execute.args_to_matching_eager([values], _ctx)
        _inputs_flat = [values]
        _attrs = ('T', _attr_T, 'shape', shape)
        _result = _execute.execute(b'PeriodicResample', 1, inputs=_inputs_flat, attrs=_attrs, ctx=_ctx, name=name)
    _execute.record_gradient('PeriodicResample', _inputs_flat, _attrs, _result, name)
    (_result,) = _result
    return _result
Periodically resample elements of a tensor to conform to `shape`.

This function implements a slightly more generic version of the subpixel
convolutions found in this [paper](https://arxiv.org/abs/1609.05158).

The formula for computing the elements in the `output` tensor is as follows:
  `T` = `values` tensor of rank `R`
  `S` = desired `shape` of output tensor (vector of length `R`)
  `P` = `output` tensor of rank `R`
  \((T_1,\ldots,T_R)\) = shape(`T`)
  \([S_1,\ldots,S_q,\ldots,S_R]\) = elements of vector `S`

  A single element in `S` is left unspecified (denoted \(S_q=-1\)).
  Let \(f_i\) denote the (possibly non-integer) factor that relates the original
  dimension to the desired dimensions, \(S_i=f_i T_i\), for \(i\neq q\) where
  \(f_i>0\).
  Define the following:
    \(g_i=\lceil f_i\rceil\)
    \(t=\prod_i T_i\)
    \(s=\prod_{i\neq q} S_i\)
  \(S_q\) can then be defined as by \(S_q=\lfloor t/s\rfloor\).
  The elements of the resulting tensor are defined as
  \(P_{s_1,\ldots,s_R}=T_{h_1,\ldots,h_q,\ldots,h_R}\).
  The \(h_i\) (\(i\neq q\)) are defined by \(h_i=\lfloor s_i/g_i\rfloor\).
  \(h_q=S_q\sum_{j\neq q}^{q-1}G_j \mathrm{mod}(s_j,g_j) + s_q\), where
  \(G_j=\prod_{i}^{j-1}g_i\) (\(G_0=1\)).

One drawback of this method is that whenever the output dimensions are slightly
less than integer multiples of the input dimensions, many of the tensor elements
are repeated in an inefficient way. This is resolved by specifying that all
desired dimensions are integer multiples of the input tensor.

For example:

```prettyprint
`input` is [[ 0  1  2  3]
            [ 4  5  6  7]
            [ 8  9 10 11]]

tf.periodic_resample(input, [6, None]) ==> [[ 0  1]
                                            [ 2  3]
                                            [ 4  5]
                                            [ 6  7]
                                            [ 8  9]
                                            [10 11]]
```

Args:
  values: A `Tensor`. Must be one of the following types: `float32`, `float64`, `int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`, `complex128`, `qint8`, `quint8`, `qint32`, `half`, `uint32`, `uint64`, `bfloat16`.
    The tensor of rank `R` to periodic_resample
  shape: A `tf.TensorShape` or list of `ints`.
    A 1-D tensor representing the desired shape of the output tensor.
    Exactly one element of this tensor must have the value `None` which represents
    that this dimension of `values` can be adjusted downward in order to
    accommodate increases in other dimensions. The specified sizes of the
    non-adjustable dimensions must by at least as large as in the `values` tensor.
  name: A name for the operation (optional).

Returns:
  A `Tensor`. Has the same type as `values`.
  Periodically resampled tensor that has dimensions specified as in
  `shape` except that the dimension specified as `None` will be minimally
  decreased as necessary.
@tf_export('PeriodicResample')
def periodic_resample(values, shape, name=None):
    'Periodically resample elements of a tensor to conform to `shape`.\n\n  This function implements a slightly more generic version of the subpixel\n  convolutions found in this [paper](https://arxiv.org/abs/1609.05158).\n\n  The formula for computing the elements in the `output` tensor is as follows:\n    `T` = `values` tensor of rank `R`\n    `S` = desired `shape` of output tensor (vector of length `R`)\n    `P` = `output` tensor of rank `R`\n    \\((T_1,\\ldots,T_R)\\) = shape(`T`)\n    \\([S_1,\\ldots,S_q,\\ldots,S_R]\\) = elements of vector `S`\n\n    A single element in `S` is left unspecified (denoted \\(S_q=-1\\)).\n    Let \\(f_i\\) denote the (possibly non-integer) factor that relates the original\n    dimension to the desired dimensions, \\(S_i=f_i T_i\\), for \\(i\\neq q\\) where\n    \\(f_i>0\\).\n    Define the following:\n      \\(g_i=\\lceil f_i\\rceil\\)\n      \\(t=\\prod_i T_i\\)\n      \\(s=\\prod_{i\\neq q} S_i\\)\n    \\(S_q\\) can then be defined as by \\(S_q=\\lfloor t/s\\rfloor\\).\n    The elements of the resulting tensor are defined as\n    \\(P_{s_1,\\ldots,s_R}=T_{h_1,\\ldots,h_q,\\ldots,h_R}\\).\n    The \\(h_i\\) (\\(i\\neq q\\)) are defined by \\(h_i=\\lfloor s_i/g_i\\rfloor\\).\n    \\(h_q=S_q\\sum_{j\\neq q}^{q-1}G_j \\mathrm{mod}(s_j,g_j) + s_q\\), where\n    \\(G_j=\\prod_{i}^{j-1}g_i\\) (\\(G_0=1\\)).\n\n  One drawback of this method is that whenever the output dimensions are slightly\n  less than integer multiples of the input dimensions, many of the tensor elements\n  are repeated in an inefficient way. This is resolved by specifying that all\n  desired dimensions are integer multiples of the input tensor.\n\n  For example:\n\n  ```prettyprint\n  `input` is [[ 0  1  2  3]\n              [ 4  5  6  7]\n              [ 8  9 10 11]]\n\n  tf.periodic_resample(input, [6, None]) ==> [[ 0  1]\n                                              [ 2  3]\n                                              [ 4  5]\n                                              [ 6  7]\n                                              [ 8  9]\n                                              [10 11]]\n  ```\n\n  Args:\n    values: A `Tensor`. Must be one of the following types: `float32`, `float64`, `int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`, `complex128`, `qint8`, `quint8`, `qint32`, `half`, `uint32`, `uint64`, `bfloat16`.\n      The tensor of rank `R` to periodic_resample\n    shape: A `tf.TensorShape` or list of `ints`.\n      A 1-D tensor representing the desired shape of the output tensor.\n      Exactly one element of this tensor must have the value `None` which represents\n      that this dimension of `values` can be adjusted downward in order to\n      accommodate increases in other dimensions. The specified sizes of the\n      non-adjustable dimensions must by at least as large as in the `values` tensor.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `Tensor`. Has the same type as `values`.\n    Periodically resampled tensor that has dimensions specified as in\n    `shape` except that the dimension specified as `None` will be minimally\n    decreased as necessary.\n  '
    shape = _execute.make_shape(shape, 'shape')
    _ctx = _context.context()
    if _ctx.in_graph_mode():
        (_, _, _op) = _op_def_lib._apply_op_helper('PeriodicResample', values=values, shape=shape, name=name)
        _result = _op.outputs[:]
        _inputs_flat = _op.inputs
        _attrs = ('T', _op.get_attr('T'), 'shape', _op.get_attr('shape'))
    else:
        (_attr_T, (values,)) = _execute.args_to_matching_eager([values], _ctx)
        _inputs_flat = [values]
        _attrs = ('T', _attr_T, 'shape', shape)
        _result = _execute.execute(b'PeriodicResample', 1, inputs=_inputs_flat, attrs=_attrs, ctx=_ctx, name=name)
    _execute.record_gradient('PeriodicResample', _inputs_flat, _attrs, _result, name)
    (_result,) = _result
    return _result