parameters: (data)
docstring: If `data` is scalar, then add a dimension; otherwise return as-is.
docstring_summary: If `data` is scalar, then add a dimension; otherwise return as-is.
docstring_tokens: If data is scalar then add a dimension ; otherwise return as - is .
function: def _with_nonzero_rank(data):
    """If `data` is scalar, then add a dimension; otherwise return as-is."""
    if data.shape.ndims is not None:
      if data.shape.ndims == 0:
        return stack([data])
      else:
        return data
    else:
      data_shape = shape(data)
      data_ndims = rank(data)
      return reshape(data, concat([[1], data_shape], axis=0)[-data_ndims:])
function_tokens: def _with_nonzero_rank ( data ) : if data . shape . ndims is not None : if data . shape . ndims == 0 : return stack ( [ data ] ) else : return data else : data_shape = shape ( data ) data_ndims = rank ( data ) return reshape ( data , concat ( [ [ 1 ] , data_shape ] , axis = 0 ) [ - data_ndims : ] )