code: def to_ndarray(x, to_ndim, axis=0):
      x = _np.array(x)
      if x.ndim == to_ndim - 1:
          x = _np.expand_dims(x, axis=axis)
  
      if x.ndim != 0 and x.ndim < to_ndim:
          raise ValueError("The ndim was not adapted properly.")
      return x
  
file_path: geomstats/geomstats/_backend/_shared_numpy/_common.py
imports: from geomstats._backend._dtype_utils import _np_box_binary_scalar
  from geomstats._backend._dtype_utils import _np_box_unary_scalar
  from geomstats._backend._dtype_utils import _pre_add_default_dtype_by_casting, _pre_allow_complex_dtype, _pre_cast_fout_to_input_dtype, _pre_cast_out_from_dtype, _pre_cast_out_to_input_dtype, _pre_set_default_dtype
  from .._backend_config import np_atol
  from .._backend_config import np_rtol
  from ._dispatch import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: to_ndarray(x, to_ndim, axis) and returns: x