class_docstr: Transformer Model for Similarity between two strings.
  
  This model defines the architecture using two transformer
  networks, each of which embed a string and the loss is
  calculated as a Binary Cross-Entropy loss. Normalized
  Dot Product is used as the distance measure between two
  string embeddings.
class_docstr_tok: ["Transformer","Model","for","Similarity","between","two","strings",".","This","model","defines","the","architecture","using","two","transformer","networks",",","each","of","which","embed","a","string","and","the","loss","is","calculated","as","a","Binary","Cross-Entropy","loss",".","Normalized","Dot","Product","is","used","as","the","distance","measure","between","two","string","embeddings","."]
code: def encode(self, features, input_key):
      hparams = self._hparams
      inputs = common_layers.flatten4d3d(features[input_key])
  
      (
          encoder_input,
          encoder_self_attention_bias,
          _,
      ) = transformer.transformer_prepare_encoder(
          inputs, problem.SpaceID.EN_TOK, hparams
      )
  
      encoder_input = tf.nn.dropout(
          encoder_input, 1.0 - hparams.layer_prepostprocess_dropout
      )
      encoder_output = transformer.transformer_encoder(
          encoder_input,
          encoder_self_attention_bias,
          hparams,
          nonpadding=transformer.features_to_nonpadding(
              features, input_key
          ),
      )
  
      encoder_output = tf.reduce_mean(encoder_output, axis=1)
  
      return encoder_output
  
file_path: tensor2tensor/tensor2tensor/models/research/similarity_transformer.py
imports: from tensor2tensor.data_generators import problem
  from tensor2tensor.layers import common_layers
  from tensor2tensor.models import transformer
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 3 for calling the SimilarityTransformer obj's underlying member method code with example usage: obj.encode(features, input_key) and returns: encoder_output