code: def _num_samples(x):
      
      if not hasattr(x, '__len__') and not hasattr(x, 'shape'):
          if hasattr(x, '__array__'):
              x = np.asarray(x)
          else:
              raise TypeError("Expected sequence or array-like, got %r" % x)
      return x.shape[0] if hasattr(x, 'shape') else len(x)
docs: Return number of samples in array-like x.