code: def _preprocess_keras_inputs(
      context_keras_inputs,
      example_keras_inputs,
      tf_transform_output,
      hparams,
  ):
      """Preprocesses the inputs, including vocab lookup and embedding."""
      lookup_layer = (
          tf.keras.layers.experimental.preprocessing.StringLookup(
              max_tokens=(
                  tf_transform_output.vocabulary_size_by_name(
                      "shared_vocab"
                  )
                  + 1
              ),
              vocabulary=tf_transform_output.vocabulary_file_by_name(
                  "shared_vocab"
              ),
              num_oov_indices=1,
              oov_token="[UNK#]",
              mask_token=None,
          )
      )
      embedding_layer = tf.keras.layers.Embedding(
          input_dim=(
              tf_transform_output.vocabulary_size_by_name(
                  "shared_vocab"
              )
              + 1
          ),
          output_dim=hparams["embedding_dimension"],
          embeddings_initializer=None,
          embeddings_constraint=None,
      )
  
      def embedding(input_tensor):
          # TODO(b/158673891): Support weighted features.
          embedded_tensor = embedding_layer(lookup_layer(input_tensor))
          mean_embedding = tf.reduce_mean(embedded_tensor, axis=-2)
          # mean_embedding could be a dense tensor (context feature) or a ragged
          # tensor (example feature). if it's ragged, we densify it first.
          if isinstance(mean_embedding.type_spec, tf.RaggedTensorSpec):
              return struct2tensor_parsing_utils.make_ragged_densify_layer()(
                  mean_embedding
              )
          return mean_embedding
  
      preprocessed_context_features, preprocessed_example_features = (
          {},
          {},
      )
      context_features, example_features, _ = features.get_features()
      for feature in context_features:
          preprocessed_context_features[feature.name] = embedding(
              context_keras_inputs[feature.name]
          )
      for feature in example_features:
          preprocessed_example_features[feature.name] = embedding(
              example_keras_inputs[feature.name]
          )
      list_size = (
          struct2tensor_parsing_utils.make_ragged_densify_layer()(
              context_keras_inputs[features.LIST_SIZE_FEATURE_NAME]
          )
      )
      list_size = tf.reshape(list_size, [-1])
      mask = tf.sequence_mask(list_size)
  
      return (
          preprocessed_context_features,
          preprocessed_example_features,
          mask,
      )
  
file_path: tfx/tfx/examples/ranking/ranking_utils.py
imports: import tensorflow
  import tensorflow_ranking
  import tensorflow_transform
  from tfx.examples.ranking import features
  from tfx.examples.ranking import struct2tensor_parsing_utils
  from tfx_bsl.public import tfxio
label_desc: Use image node_id 5 for calling a global function with example usage: _preprocess_keras_inputs(context_keras_inputs, example_keras_inputs, tf_transform_output, hparams) and returns: preprocessed_context_features,  preprocessed_example_features,  mask, mean_embedding, struct2tensor_parsing_utils