code: def testConv1DTransposeValid(self):
      with self.cached_session():
          strides = [1, 2, 1]
  
          # Input, output: [batch, width, depth]
          x_shape = [2, 4, 3]
          y_shape = [2, 9, 2]
  
          # Filter: [kernel_width, output_depth, input_depth]
          f_shape = [3, 2, 3]
  
          x = constant_op.constant(
              1.0, shape=x_shape, name="x", dtype=dtypes.float32
          )
          f = constant_op.constant(
              1.0, shape=f_shape, name="filter", dtype=dtypes.float32
          )
          output = nn_ops.conv1d_transpose(
              x, f, y_shape, strides=strides, padding="VALID"
          )
          value = self.evaluate(output)
  
          cache_values = np.zeros(y_shape, dtype=np.float32)
  
          # The amount of padding added
          pad = 1
  
          for n in range(x_shape[0]):
              for k in range(f_shape[1]):
                  for w in range(pad, y_shape[1] - pad):
                      target = 3.0
                      # We add a case for locations divisible by the stride.
                      w_in = (
                          w % strides[1] == 0
                          and w > pad
                          and w < y_shape[1] - 1 - pad
                      )
                      if w_in:
                          target += 3.0
                      cache_values[n, w, k] = target
  
                  # copy values in the border
                  cache_values[n, 0, k] = cache_values[n, 1, k]
                  cache_values[n, -1, k] = cache_values[n, -2, k]
                  cache_values[n, :, k] = cache_values[n, :, k]
  
      self.assertAllClose(cache_values, value)
  
file_path: tensorflow-upstream/tensorflow/python/kernel_tests/nn_ops/conv1d_transpose_test.py
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import gradient_checker
  from tensorflow.python.ops import nn_ops
  import tensorflow.python.ops.nn_grad
  from tensorflow.python.platform import test
label_desc: Use image node_id 3 for calling the Conv1DTransposeTest obj's underlying member method code with example usage: obj.testConv1DTransposeValid() without return types