def convert_dict_to_compatible_tensor(values, targets):
  """Converts dict `values` in tensors that are compatible with `targets`.

  Args:
    values: A dict to objects to convert with same keys as `targets`.
    targets: A dict returned by `parse_tensor_info_map`.

  Returns:
    A map with the same keys as `values` but values converted into
    Tensor/SparseTensors that can be fed into `protomap`.

  Raises:
    TypeError: If it fails to convert.
  """
  result = {}
  for key, value in sorted(values.items()):
    result[key] = _convert_to_compatible_tensor(
        value, targets[key], error_prefix="Can't convert %r" % key)
  return result
Converts dict `values` in tensors that are compatible with `targets`.

  Args:
    values: A dict to objects to convert with same keys as `targets`.
    targets: A dict returned by `parse_tensor_info_map`.

  Returns:
    A map with the same keys as `values` but values converted into
    Tensor/SparseTensors that can be fed into `protomap`.

  Raises:
    TypeError: If it fails to convert.