code: def _to_dense_tensor(
      values: np.ndarray,
      indices: np.ndarray,
      dense_shape: Tuple[int, ...],
  ) -> np.ndarray:
      """Converts sparse tensor to dense given values, indices, and dense shape."""
      # Squeeze is used on the values, indices, and result to ensure that single
      # value inputs that still have the batch dimension such as [1, n_classes] can
      # still be indexed properly from SparseTensorValues that don't use batching.
      result = _squeeze(np.zeros(dense_shape, dtype=values.dtype))
      for value, index in zip(_squeeze(values), _squeeze(indices)):
          result[index] = value
      return result.reshape(dense_shape)
  
imports: import inspect
  import math
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import util
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 21 for calling a global function with example usage: _to_dense_tensor(values, indices, dense_shape) and returns: result