class_docstr: Stores any kind of features ready to be used by a RasaModel.
  
  Next to the input numpy array of features, it also received the number of
  dimensions of the features.
  As our features can have 1 to 4 dimensions we might have different number of numpy
  arrays stacked. The number of dimensions helps us to figure out how to handle this
  particular feature array. Also, it is automatically determined whether the feature
  array is sparse or not and the number of units is determined as well.
  
  Subclassing np.array: https://numpy.org/doc/stable/user/basics.subclassing.html
class_docstr_tok: ["Stores","any","kind","of","features","ready","to","be","used","by","a","RasaModel",".","Next","to","the","input","numpy","array","of","features",",","it","also","received","the","number","of","dimensions","of","the","features",".","As","our","features","can","have","1","to","4","dimensions","we","might","have","different","number","of","numpy","arrays","stacked",".","The","number","of","dimensions","helps","us","to","figure","out","how","to","handle","this","particular","feature","array",".","Also",",","it","is","automatically","determined","whether","the","feature","array","is","sparse","or","not","and","the","number","of","units","is","determined","as","well",".","Subclassing","np.array",":","https",":","\/\/numpy.org\/doc\/stable\/user\/basics.subclassing.html"]
docstr: Validates if the the input array has given number of dimensions.
  
  Args:
      number_of_dimensions: number of dimensions
      input_array: input array
  
  Raises: ValueError in case the dimensions do not match
docstr_tok: ["Validates","if","the","the","input","array","has","given","number","of","dimensions",".","Args",":","number_of_dimensions",":","number","of","dimensions","input_array",":","input","array","Raises",":","ValueError","in","case","the","dimensions","do","not","match"]
code: def _validate_number_of_dimensions(
      number_of_dimensions: int, input_array: np.ndarray
  ) -> None:
      """Validates if the the input array has given number of dimensions.
  
      Args:
          number_of_dimensions: number of dimensions
          input_array: input array
  
      Raises: ValueError in case the dimensions do not match
      """
      _sub_array = input_array
      dim = 0
      # Go number_of_dimensions into the given input_array
      for i in range(1, number_of_dimensions + 1):
          _sub_array = _sub_array[0]
          if isinstance(_sub_array, scipy.sparse.spmatrix):
              dim = i
              break
          if (
              isinstance(_sub_array, np.ndarray)
              and _sub_array.shape[0] == 0
          ):
              # sequence dimension is 0, we are dealing with "fake" features
              dim = i
              break
  
      # If the resulting sub_array is sparse, the remaining number of dimensions
      # should be at least 2
      if isinstance(_sub_array, scipy.sparse.spmatrix):
          if dim > 2:
              raise ValueError(
                  f"Given number of dimensions '{number_of_dimensions}' does not "
                  f"match dimensions of given input array: {input_array}."
              )
      elif (
          isinstance(_sub_array, np.ndarray)
          and _sub_array.shape[0] == 0
      ):
          # sequence dimension is 0, we are dealing with "fake" features,
          # but they should be of dim 2
          if dim > 2:
              raise ValueError(
                  f"Given number of dimensions '{number_of_dimensions}' does not "
                  f"match dimensions of given input array: {input_array}."
              )
      # If the resulting sub_array is dense, the sub_array should be a single number
      elif not np.issubdtype(
          type(_sub_array), np.integer
      ) and not isinstance(_sub_array, (np.float32, np.float64)):
          raise ValueError(
              f"Given number of dimensions '{number_of_dimensions}' does not match "
              f"dimensions of given input array: {input_array}."
          )
  
imports: import logging
  from typing import Optional, DefaultDict, Dict, Iterable, Text, List, Tuple, Any, Union, NamedTuple, ItemsView, overload, cast
  from collections import defaultdict, OrderedDict
  import numpy
  import scipy.sparse
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 7 for calling the FeatureArray obj's underlying member method code with example usage: obj._validate_number_of_dimensions(number_of_dimensions, input_array) without return types