code: def cluster(
      data,
      method="kmeans",
      dim_method="pca",
      compute_backend=None,
      viz_backend=None,
      **kwargs,
  ) -> ClusterWidget:
      """Unsupervised determination of clusters.
  
      This feature computes clusters using various algorithms (KMeans, HDBSCAN) and then
      projects the data onto a two-dimensional plot for visualization.
  
      Args:
          data (DataFrame): The data.
          method (str, optional): {'kmeans', 'hdbscan'} The clustering method.
          dim_method (str, optional): The method to use for dimensionality reduction.
          compute_backend (str, optional): The compute backend.
          viz_backend (str, optional): The visualization backend.
          n_clusters (Optional[int], optional): (KMeans) The number of clusters.
          cluster_range (Tuple[int, int], optional): (KMeans) A tuple of the minimum and
              maximum cluster search range. Defaults to (2, 20).
          metric (str): (KMeans) The metric to optimize (from sklearn.metrics).
          target: (KMeans) The labels for supervised clustering, as a 1-D array.
          **kwargs: Keyword arguments.
  
      Raises:
          ValueError: Data frame required
          ValueError: Clustering method not implemented
  
      Returns:
          ClusterWidget
      """
      if not _is_dataframe(data):
          raise ValueError("Data frame required")
  
      if method not in ["kmeans", "hdbscan"]:
          raise ValueError(f"{method} not implemented")
  
      data = data.select_dtypes("number")
  
      clusterwidget = _get_compute_backend(
          compute_backend, data
      ).compute_cluster(data=data, method=method, **kwargs)
  
      viz_data, reductor = dim_reduc(
          clusterwidget.scaled_data, 2, dim_method=dim_method
      )
      viz_data.columns = ["x", "y"]
      viz_data["clusters"] = clusterwidget.clusters
  
      clusterwidget.viz_data = viz_data
      clusterwidget.reductor = reductor
  
      if dim_method == "pca":
          var_explained = (
              np.round(reductor.explained_variance_ratio_[:2], 2) * 100
          )
          clusterwidget.xlabel = (
              f"Component 1 ({var_explained[0]}% variance explained)"
          )
          clusterwidget.ylabel = (
              f"Component 2 ({var_explained[1]}% variance explained)"
          )
      else:
          clusterwidget.xlabel = "Dimension 1"
          clusterwidget.ylabel = "Dimension 2"
  
      clusterwidget.viz_backend = viz_backend
  
      return clusterwidget
  
imports: from typing import Optional, Tuple, List, Union
  import pandas
  import numpy
  import seaborn
  import sklearn
  from sklearn.cluster import KMeans
  import matplotlib.pyplot
  from matplotlib.ticker import MaxNLocator
  from sklearn.preprocessing import StandardScaler
  import plotly.graph_objs
  import plotly.offline
  from data_describe.config._config import get_option
  from data_describe._widget import BaseWidget
  from data_describe.compat import _is_dataframe, _compat, _requires, _in_notebook
  from data_describe.backends import _get_viz_backend, _get_compute_backend
  from data_describe.dimensionality_reduction.dimensionality_reduction import dim_reduc
label_desc: Use image node_id 1 for calling a global function with example usage: cluster(data, method, dim_method, compute_backend, viz_backend) and returns: clusterwidget