def unravel_index_2d(indices, dims):
  """Unravel index, for 2D inputs only.

  See Numpy's unravel.

  Args:
    indices: <int32> [num_elements], coordinates into 2D row-major tensor.
    dims: (N, M), dimensions of the 2D tensor.

  Returns:
    coordinates: <int32> [2, num_elements], row (1st) and column (2nd) indices.
  """
  row_inds = tf.floordiv(indices, dims[1])
  col_inds = tf.floormod(indices, dims[1])
  return tf.stack([row_inds, col_inds], axis=0)
Unravel index, for 2D inputs only.

  See Numpy's unravel.

  Args:
    indices: <int32> [num_elements], coordinates into 2D row-major tensor.
    dims: (N, M), dimensions of the 2D tensor.

  Returns:
    coordinates: <int32> [2, num_elements], row (1st) and column (2nd) indices.
  
language/capwap/utils/tensor_utils.py