class_docstr: Tests params, residual capabilities, padding leaks, and output shape.
code: def test_encoder_layer(self, translation_layer_name, output_depth):
      with self.test_session(graph=tf.Graph()) as sess:
          nonpadding_list = _create_nonpadding_list()
          for prefix in _RESIZE_EXEMPT_LAYER_PREFIXES:
              if prefix in translation_layer_name:
                  output_depth = _INPUT_DEPTH
          translation_layer = layers.ENCODER_LAYERS.get(
              translation_layer_name
          )
          output_tensor = _apply_encoder_layer(
              translation_layer, output_depth, nonpadding_list
          )
  
          # Check that the output shape is as expected.
          self.assertEqual(
              output_tensor.shape.as_list(),
              [_BATCH_SIZE, _TOTAL_SEQUENCE_LENGTH, output_depth],
          )
  
          # Check that the number of parameters is as expected.
          empirical_num_params = _get_empirical_parameters()
          reported_num_params = translation_layer.num_params(
              _INPUT_DEPTH, output_depth
          )
          self.assertEqual(empirical_num_params, reported_num_params)
  
          # Make sure padding is applied properly (no leaks).
          sess.run(tf.global_variables_initializer())
          output = sess.run(output_tensor)
  
      for i, j in itertools.product(
          range(_BATCH_SIZE), range(_TOTAL_SEQUENCE_LENGTH)
      ):
          if nonpadding_list[i][j] == 0:
              self.assertAllEqual(
                  output[i][j],
                  np.array([0] * output_depth),
                  "Output row %s, column %s not zeroed out." % (i, j),
              )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import itertools
  from absl.testing import parameterized
  import numpy
  from tensor2tensor.layers import common_attention
  from tensor2tensor.models import transformer
  from tensor2tensor.models.neural_architecture_search import nas_layers
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the LayersTest obj's underlying member method code with example usage: obj.test_encoder_layer(translation_layer_name, output_depth) without return types