def _numericalize_coefficients(raw_symbols, coefficients):
  """Replaces the symbols of coefficients in the expression string with values.

  If there is coefficient symbol in raw_symbols which is not in coefficients
  dict, it will remain symbolic in the expression string.

  Args:
    raw_symbols: List of context-free grammar symbols or strings.
    coefficients: Dict of coefficients values in expression string.
        {coefficient_symbol: value}. If not None, the values of the
        coefficients will replace the symbols of coefficients in the
        expression string.

  Returns:
    Expression string.
  """
  if coefficients is None:
    coefficients = {}
  symbols = []
  for symbol in map(str, raw_symbols):
    if symbol in coefficients:
      symbols.append(str(coefficients[symbol]))
    else:
      symbols.append(symbol)
  return ' '.join(symbols)