code: def gower_matrix(
      data: np.ndarray, cat_features: np.array
  ) -> np.ndarray:
      """
      Calculate distance matrix for a dataset using Gower's method.
  
      Gowers distance is a measurement for distance between two samples. It returns the average of their distances
      per feature. For numeric features it calculates the absolute distance divide by the range of the feature. For
      categorical features it is an indicator whether the values are the same.
      See https://www.jstor.org/stable/2528823 for further details. In addition, it can deal with missing values.
      Note that this method is expensive in memory and requires keeping in memory a matrix of size data*data.
  
      Parameters
      ----------
      data: numpy.ndarray
          Dataset matrix.
      cat_features: numpy.array
          Boolean array of representing which of the columns are categorical features.
  
      Returns
      -------
      numpy.ndarray
       representing the distance matrix.
      """
      if not isinstance(data, np.ndarray):
          data = np.asarray(data)
  
      feature_ranges = np.ones(data.shape[1]) * -1
      feature_ranges[~cat_features] = np.nanmax(
          data[:, ~cat_features], axis=0
      ) - np.nanmin(data[:, ~cat_features], axis=0)
  
      result = np.zeros((data.shape[0], data.shape[0]))
      for i in range(data.shape[0]):
          for j in range(i, data.shape[0]):
              value = calculate_distance(
                  data[i, :], data[j, :], feature_ranges
              )
              result[i, j] = value
              result[j, i] = value
  
      return result
  
file_path: deepchecks/deepchecks/utils/gower_distance.py
imports: from typing import Hashable, List
  import numpy
  import pandas
  from deepchecks.utils.array_math import fast_sum_by_row
label_desc: Use image node_id 1 for calling a global function with example usage: gower_matrix(data, cat_features) and returns: result