code: def _num_features(X, fallback_1d=False):
      type_ = type(X)
      if type_.__module__ == "builtins":
          type_name = type_.__qualname__
      else:
          type_name = f"{type_.__module__}.{type_.__qualname__}"
      message = (
          "Unable to find the number of features from X of type "
          f"{type_name}"
      )
      if not hasattr(X, "__len__") and not hasattr(X, "shape"):
          if not hasattr(X, "__array__"):
              raise TypeError(message)
          # Only convert X to a numpy array if there is no cheaper, heuristic
          # option.
          X = np.asarray(X)
  
      if hasattr(X, "shape"):
          ndim_thr = 1 if fallback_1d else 2
          if not hasattr(X.shape, "__len__") or len(X.shape) < ndim_thr:
              message += f" with shape {X.shape}"
              raise TypeError(message)
          return X.shape[-1]
  
      first_sample = X[0]
  
      # Do not consider an array-like of strings or dicts to be a 2D array
      if isinstance(first_sample, (str, bytes, dict)):
          message += (
              f" where the samples are of type "
              f"{type(first_sample).__qualname__}"
          )
          raise TypeError(message)
  
      try:
          # If X is a list of lists, for instance, we assume that all nested
          # lists have the same length without checking or converting to
          # a numpy array to keep this function call as cheap as possible.
          if (not fallback_1d) or hasattr(first_sample, "__len__"):
              return len(first_sample)
          else:
              return 1
      except Exception as err:
          raise TypeError(message) from err
  
imports: import warnings
  from collections.abc import Sequence
  from numbers import Integral
  import numpy
  from scipy import sparse
  from sklearn.preprocessing import LabelEncoder
  from sklearn.utils.validation import check_array
  from daal4py.sklearn.utils.validation import _assert_all_finite
label_desc: Use image node_id 13 for calling a global function with example usage: _num_features(X, fallback_1d) and returns: X, len, int