code: def check_array(
      array,
      *args,
      accept_dask_array=True,
      accept_dask_dataframe=False,
      accept_unknown_chunks=False,
      accept_multiple_blocks=False,
      preserve_pandas_dataframe=False,
      remove_zero_chunks=True,
      **kwargs,
  ):
      """Validate inputs
  
      Parameters
      ----------
      accept_dask_array : bool, default True
      accept_dask_dataframe : bool, default False
      accept_unknown_chunks : bool, default False
          For dask Arrays, whether to allow the `.chunks` attribute to contain
          any unknown values
      accept_multiple_blocks : bool, default False
          For dask Arrays, whether to allow multiple blocks along the second
          axis.
      *args, **kwargs : tuple, dict
          Passed through to scikit-learn
  
      Returns
      -------
      array : obj
          Same type as the input
  
      Notes
      -----
      For dask.array, a small numpy array emulating ``array`` is created
      and passed to scikit-learn's ``check_array`` with all the additional
      arguments.
      """
      if isinstance(array, da.Array):
          if not accept_dask_array:
              raise TypeError
          if not accept_unknown_chunks:
              if np.isnan(array.shape[0]):
                  raise TypeError(
                      "Cannot operate on Dask array with unknown chunk sizes. "
                      "Use the following the compute chunk sizes:\n\n"
                      "   >>> X.compute_chunk_sizes()  # if Dask.Array\n"
                      "   >>> ddf.to_dask_array(lengths=True)  # if Dask.Dataframe"
                  )
          if not accept_multiple_blocks and array.ndim > 1:
              if len(array.chunks[1]) > 1:
                  msg = (
                      "Chunking is only allowed on the first axis. "
                      "Use 'array.rechunk({1: array.shape[1]})' to "
                      "rechunk to a single block along the second axis."
                  )
                  raise TypeError(msg)
  
          if remove_zero_chunks:
              if min(array.chunks[0]) == 0:
                  # scikit-learn does not gracefully handle length-0 chunks
                  # in some cases (e.g. pairwise_distances).
                  chunks2 = tuple(x for x in array.chunks[0] if x != 0)
                  array = array.rechunk({0: chunks2})
  
          # hmmm, we want to catch things like shape errors.
          # I'd like to make a small sample somehow
          shape = array.shape
          if len(shape) == 2:
              shape = (min(10, shape[0]), shape[1])
          elif shape == 1:
              shape = min(10, shape[0])
  
          sample = np.ones(shape=shape, dtype=array.dtype)
          sk_validation.check_array(sample, *args, **kwargs)
          return array
  
      elif isinstance(array, dd.DataFrame):
          if not accept_dask_dataframe:
              raise TypeError(
                  "This estimator does not support dask dataframes. "
                  "This might be resolved with one of\n\n"
                  "    1. ddf.to_dask_array(lengths=True)\n"
                  "    2. ddf.to_dask_array()  # may cause other issues because "
                  "of unknown chunk sizes"
              )
          # TODO: sample?
          return array
      elif (
          isinstance(array, pd.DataFrame) and preserve_pandas_dataframe
      ):
          # TODO: validation?
          return array
      else:
          return sk_validation.check_array(array, *args, **kwargs)
  
imports: import contextlib
  import datetime
  import functools
  import logging
  import warnings
  from collections.abc import Sequence
  from multiprocessing import cpu_count
  from numbers import Integral
  from timeit import default_timer
  import dask
  import dask.array
  import dask.dataframe
  import numpy
  import pandas
  import sklearn.utils.extmath
  import sklearn.utils.validation
  from dask import delayed
  from dask.array.utils import assert_eq
  from dask.dataframe.utils import assert_eq
  from ._utils import ConstantFunction
label_desc: Use image node_id 8 for calling a global function with example usage: check_array(array) and returns: array, array, array, sk_validation