code: def _num_samples(x):
      """Return number of samples in array-like x."""
      message = "Expected sequence or array-like, got %s" % type(x)
      if hasattr(x, "fit") and callable(x.fit):
          # Don't get num_samples from an ensembles length!
          raise TypeError(message)
  
      if not hasattr(x, "__len__") and not hasattr(x, "shape"):
          if hasattr(x, "__array__"):
              x = np.asarray(x)
          else:
              raise TypeError(message)
  
      if hasattr(x, "shape") and x.shape is not None:
          if len(x.shape) == 0:
              raise TypeError(
                  "Singleton array %r cannot be considered a valid collection."
                  % x
              )
          # Check that shape is returning an integer or default to len
          # Dask dataframes may not return numeric shape[0] value
          if isinstance(x.shape[0], numbers.Integral):
              return x.shape[0]
  
      try:
          return len(x)
      except TypeError as type_error:
          raise TypeError(message) from type_error
  
imports: import functools
  import logging
  import numbers
  import time
  import warnings
  from collections import Counter
  from contextlib import suppress
  from itertools import compress
  from traceback import format_exc
  import numpy
  import scipy.sparse
  from catboost import CatBoostClassifier, CatBoostRegressor
  from joblib import Parallel, logger
  from scipy.sparse import issparse
  from sklearn import config_context, get_config
  from sklearn.base import clone, is_classifier
  from sklearn.exceptions import FitFailedWarning, NotFittedError
  from sklearn.metrics import check_scoring
  from sklearn.metrics._scorer import _MultimetricScorer
  from sklearn.model_selection import check_cv
  from sklearn.utils.fixes import np_version, parse_version
  from sklearn.utils.validation import indexable
label_desc: Use image node_id 21 for calling a global function with example usage: _num_samples(x) and returns: len, x