def slice_X(X, start=None, stop=None):
 if isinstance(X, list):
  if hasattr(start, '__len__'):
   if hasattr(start, 'shape'):
    start = start.tolist()
   return [x[start] for x in X]
  else:
   return [x[start:stop] for x in X]
 elif hasattr(start, '__len__'):
  if hasattr(start, 'shape'):
   start = start.tolist()
  return X[start]
 else:
  return X[start:stop]

def slice_X ( X , start = None , stop = None ) : if isinstance ( X , list ) : if hasattr ( start , '__len__' ) : if hasattr ( start , 'shape' ) : start = start . tolist ( ) return [ x [ start ] for x in X ] else : return [ x [ start : stop ] for x in X ] elif hasattr ( start , '__len__' ) : if hasattr ( start , 'shape' ) : start = start . tolist ( ) return X [ start ] else : return X [ start : stop ]
this takes an array-like .