code: def embed(X_keep, X_rest, n_components, metric, kernel_params):
      if isinstance(metric, str):
          if metric not in PAIRWISE_KERNEL_FUNCTIONS:
              msg = (
                  "Unknown affinity metric name '{}'. Expected one "
                  "of '{}'".format(
                      metric, PAIRWISE_KERNEL_FUNCTIONS.keys()
                  )
              )
              raise ValueError(msg)
          A = pairwise_kernels(
              X_keep, metric=metric, filter_params=True, **kernel_params
          )
          B = pairwise_kernels(
              X_keep,
              X_rest,
              metric=metric,
              filter_params=True,
              **kernel_params,
          )
      elif callable(metric):
          A = metric(X_keep, **kernel_params)
          B = metric(X_keep, X_rest, **kernel_params)
      else:
          msg = (
              "Unexpected type for 'affinity' '{}'. Must be string "
              "kernel name, array, or callable"
          )
          raise TypeError(msg)
      if isinstance(A, da.Array):
          A = A.rechunk((n_components, n_components))
          B = B.rechunk((B.shape[0], B.chunks[1]))
      return A, B
  
file_path: dask-ml/dask_ml/cluster/spectral.py
imports: import logging
  import dask.array
  import numpy
  import sklearn.cluster
  from dask import delayed
  from scipy.linalg import pinv, svd
  from sklearn.base import BaseEstimator, ClusterMixin
  from sklearn.utils import check_random_state
  from .._utils import draw_seed
  from ..metrics.pairwise import PAIRWISE_KERNEL_FUNCTIONS, pairwise_kernels
  from ..utils import _format_bytes, _log_array, check_array
  from .k_means import KMeans
label_desc: Use image node_id 1 for calling a global function with example usage: embed(X_keep, X_rest, n_components, metric, kernel_params) and returns: A,  B