function ndims( x ) {
	var sh;
	var n;

	// Note: we intentionally avoid rigorous ndarray checks to minimize performance impacts. This obviously means that non-ndarray-like objects can sneak through, but this is likely all right for the purposes of this function...
	if ( typeof x !== 'object' || x === null ) {
		throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
	}
	n = x.ndims;
	if ( isNonNegativeInteger( n ) ) {
		return n;
	}
	sh = x.shape;
	if ( !isCollection( sh ) ) {
		throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
	}
	return sh.length;
}
Returns the number of ndarray dimensions.

@param {ndarrayLike} x - input ndarray
@throws {TypeError} must provide an ndarray
@returns {NonNegativeInteger} number of dimensions

@example
var zeros = require( '@stdlib/ndarray/zeros' );

var n = ndims( zeros( [ 3, 3, 3 ] ) );
// returns 3