code: def pairwise_hamming_kernel(X1, X2, weights=None):
      """Computes the pairwise hamming kernels between X1 and X2."""
  
      # An internal function to compute weighted distances between an array and a vector.
      def _compute_dist_between_2D_1D_array(arr_2d, arr_1d, wts):
          """Returns distance between 2D and 1D array."""
          return (np.equal(arr_2d, arr_1d) * wts).sum(axis=1)
  
      # An internal function to compute weighted distances between a large array and
      # a small array
      def _compute_dist_between_large_small_array(
          arr_large, arr_small, wts
      ):
          """Returns distances between large and small arrays."""
          ret = np.zeros((arr_large.shape[0], arr_small.shape[0]))
          for idx, small_vec in enumerate(arr_small):
              ret[:, idx] = _compute_dist_between_2D_1D_array(
                  arr_large, small_vec, wts
              )
          return ret
  
      # ---------------------------------------------------------------------------------
      if len(X1) == 0 and len(X2) == 0:
          return np.zeros((0, 0))
      elif len(X1) == 0:
          return np.zeros((0, len(X2)))
      elif len(X2) == 0:
          return np.zeros((len(X1), 0))
      else:
          if weights is None:
              dim = len(X1[0])
              weights = np.ones((dim,)) / float(dim)
          X1 = np.array(X1, dtype=np.object)
          X2 = np.array(X2, dtype=np.object)
          n1, _ = X1.shape
          n2, _ = X2.shape
          if n2 < n1:
              return _compute_dist_between_large_small_array(
                  X2, X1, weights
              ).T
          else:
              return _compute_dist_between_large_small_array(
                  X1, X2, weights
              )
  
imports: from __future__ import print_function
  from __future__ import division
  import numpy
  from scipy.sparse import dok_matrix
  from scipy.linalg import solve_triangular
label_desc: Use image node_id 11 for calling a global function with example usage: pairwise_hamming_kernel(X1, X2, weights) and returns: unknown, ret, np, np, np, _compute_dist_between_large_small_array, _compute_dist_between_large_small_array