code: def testConv1dValidPaddingMultipleBatchDims(self):
      converter = test_utils.NumpyConverter()
      batch = 2
      outer_batch = 3
      d_model = 6
      d_out = 1
      length = 4
      filter_size = 3
  
      x = np.random.randn(outer_batch, batch, length, d_model)
      x_mtf = converter.convert_np_array_to_mtf_tensor(
          x,
          dtype=tf.float32,
          dim_names=["outer_batch", "batch", "length", "d_model"],
      )
  
      conv_filter = np.random.randn(1, filter_size, d_model, d_out)
      initializer = lambda shape, dtype, **kwargs: conv_filter
      output_mtf = mtf.layers.conv1d(
          x_mtf,
          output_dim=mtf.Dimension("output_dim", d_out),
          filter_size=filter_size,
          padding="VALID",
          filter_initializer=initializer,
      )
      actual = converter.convert_mtf_tensor_to_np_array(output_mtf)
  
      # Expected length is 2.
      expected = np.empty(
          shape=(outer_batch, batch, 2, d_out), dtype=np.float32
      )
  
      # Effective filter: [filter_size, d_model]
      f = conv_filter[0, :, :, 0]
      # o: outer_batch, b: batch, k: filter_size, d: d_model.
      expected[:, :, 0] = np.einsum(
          "obkd,kd->ob", x[:, :, :filter_size, :], f
      ).reshape(outer_batch, batch, 1)
      expected[:, :, 1] = np.einsum(
          "obkd,kd->ob", x[:, :, 1:, :], f
      ).reshape(outer_batch, batch, 1)
      self.assertAllClose(actual, expected)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import mesh_tensorflow
  from mesh_tensorflow import test_utils
  import mock
  import numpy
  import tensorflow.compat.v1
  import tensorflow_probability
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 14 for calling the LayersTest obj's underlying member method code with example usage: obj.testConv1dValidPaddingMultipleBatchDims() without return types