code: def embedding_lookup_sparse_impl(
      params,
      segment_ids,
      sp_weights,
      ids,
      combiner,
      ignore_weights,
      max_norm,
      allow_fast_lookup,
      partition_strategy,
      name,
  ):
      """Implementation of sparse embedding aggregation."""
      need_sparse_segment_gradient = False
      # Ensure we can query the devices below.
      segment_ids = ops.convert_to_tensor(
          segment_ids, name="segment_ids"
      )
      if len(params) == 1 and not isinstance(
          params[0], (core.Tensor, composite_tensor.CompositeTensor)
      ):
          params = [ops.convert_to_tensor(params[0], name="params")]
      # Note that if the params are on a different device (e.g., CPU), we must use
      # embedding_lookup() so that the gather operation is colocated with them.
      if (
          len(params) == 1
          and not isinstance(
              params[0], composite_tensor.CompositeTensor
          )
          and params[0].device == segment_ids.device
          and max_norm is None
          and (
              allow_fast_lookup
              or (
                  ignore_weights
                  and compat.forward_compatible(2023, 9, 26)
              )
          )
      ):
          idx = ids
          embeddings = params[0]
          if isinstance(
              embeddings, resource_variable_ops.BaseResourceVariable
          ):
              # Avoid a redundant copy due to copy-on-read semantics for
              # sparsely-updated variables.
              embeddings = embeddings.read_value_no_copy()
          if not allow_fast_lookup:
              need_sparse_segment_gradient = True
      else:
          ids, idx = array_ops.unique(ids)
          embeddings = embedding_lookup(
              params,
              ids,
              partition_strategy=partition_strategy,
              max_norm=max_norm,
          )
  
      if not ignore_weights:
          if segment_ids.dtype != dtypes.int32:
              segment_ids = math_ops.cast(segment_ids, dtypes.int32)
  
          weights = sp_weights.values
          embeddings = array_ops.gather(embeddings, idx)
  
          original_dtype = embeddings.dtype
          if embeddings.dtype in (dtypes.float16, dtypes.bfloat16):
              # Cast low-precision embeddings to float32 during the computation to
              # avoid numerical issues.
              embeddings = math_ops.cast(embeddings, dtypes.float32)
          if weights.dtype != embeddings.dtype:
              weights = math_ops.cast(weights, embeddings.dtype)
  
          # Reshape weights to allow broadcast
          ones_shape = array_ops.expand_dims(
              array_ops.rank(embeddings) - 1, 0
          )
          ones = array_ops.ones(ones_shape, dtype=dtypes.int32)
          bcast_weights_shape = array_ops.concat(
              [array_ops.shape(weights), ones], 0
          )
  
          orig_weights_shape = weights.get_shape()
          weights = array_ops.reshape(weights, bcast_weights_shape)
  
          # Set the weight shape, since after reshaping to bcast_weights_shape,
          # the shape becomes None.
          if embeddings.get_shape().ndims is not None:
              weights.set_shape(
                  orig_weights_shape.concatenate(
                      [
                          1
                          for _ in range(
                              embeddings.get_shape().ndims - 1
                          )
                      ]
                  )
              )
  
          embeddings *= weights
  
          if combiner == "sum":
              embeddings = math_ops.segment_sum(
                  embeddings, segment_ids, name=name
              )
          elif combiner == "mean":
              embeddings = math_ops.segment_sum(embeddings, segment_ids)
              weight_sum = math_ops.segment_sum(weights, segment_ids)
              embeddings = math_ops.div_no_nan(
                  embeddings, weight_sum, name=name
              )
          elif combiner == "sqrtn":
              embeddings = math_ops.segment_sum(embeddings, segment_ids)
              weights_squared = math_ops.pow(weights, 2)
              weight_sum = math_ops.segment_sum(
                  weights_squared, segment_ids
              )
              weight_sum_sqrt = math_ops.sqrt(weight_sum)
              embeddings = math_ops.div_no_nan(
                  embeddings, weight_sum_sqrt, name=name
              )
          else:
              assert False, "Unrecognized combiner"
          if embeddings.dtype != original_dtype:
              embeddings = math_ops.cast(embeddings, original_dtype)
      else:
          if segment_ids.dtype not in (dtypes.int32, dtypes.int64):
              segment_ids = math_ops.cast(segment_ids, dtypes.int32)
          assert idx is not None
          if combiner == "sum":
              embeddings = math_ops.sparse_segment_sum(
                  embeddings,
                  idx,
                  segment_ids,
                  name=name,
                  sparse_gradient=need_sparse_segment_gradient,
              )
          elif combiner == "mean":
              embeddings = math_ops.sparse_segment_mean(
                  embeddings,
                  idx,
                  segment_ids,
                  name=name,
                  sparse_gradient=need_sparse_segment_gradient,
              )
          elif combiner == "sqrtn":
              embeddings = math_ops.sparse_segment_sqrt_n(
                  embeddings,
                  idx,
                  segment_ids,
                  name=name,
                  sparse_gradient=need_sparse_segment_gradient,
              )
          else:
              assert False, "Unrecognized combiner"
  
      return embeddings
  
imports: from tensorflow.python.compat import compat
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import clip_ops
  from tensorflow.python.ops import data_flow_grad
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import sparse_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.types import core
  from tensorflow.python.util import dispatch
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 10 for calling a global function with example usage: embedding_lookup_sparse_impl(params, segment_ids, sp_weights, ids, combiner, ignore_weights, max_norm, allow_fast_lookup, partition_strategy, name) and returns: embeddings