code: def test_cpu_sparse_lookup(self):
      mid_level = self._create_mid_level()
      features = self._get_sparse_tensors()
      results = mid_level(features, weights=None)
      reduced = []
      for feature, config in zip(
          nest.flatten(features), self.feature_config
      ):
          table = mid_level.embedding_tables[config.table].numpy()
          all_lookups = table[feature.values.numpy()]
          # With row starts we can use reduceat in numpy. Get row starts from the
          # ragged tensor API.
          ragged = ragged_tensor.RaggedTensor.from_sparse(feature)
          row_starts = ragged.row_starts().numpy()
          reduced.append(np.add.reduceat(all_lookups, row_starts))
          if config.table.combiner == "mean":
              # for mean, divide by the row lengths.
              reduced[-1] /= np.expand_dims(
                  ragged.row_lengths().numpy(), axis=1
              )
      self.assertAllClose(
          results, nest.pack_sequence_as(results, reduced)
      )
  
imports: import numpy
  from tensorflow.python.compat import v2_compat
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.ops import init_ops_v2
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import test
  from tensorflow.python.tpu import tpu_embedding_for_serving
  from tensorflow.python.tpu import tpu_embedding_v2_utils
  from tensorflow.python.util import nest
label_desc: Use image node_id 7 for calling the TPUEmbeddingForServingTest obj's underlying member method code with example usage: obj.test_cpu_sparse_lookup() without return types