docs: def _slice(self, X, X2):
          """
          Slice the correct dimensions for use in the kernel, as indicated by
          `self.active_dims`.
          :param X: Input 1 (NxD).
          :param X2: Input 2 (MxD), may be None.
          :return: Sliced X, X2, (Nxself.input_dim).
          """
          if isinstance(self.active_dims, slice):
              X = X[..., self.active_dims]
              if X2 is not None:
                  X2 = X2[..., self.active_dims]
          else:
              X = tf.gather(X, self.active_dims, axis=-1)
              if X2 is not None:
                  X2 = tf.gather(X2, self.active_dims, axis=-1)
  
          input_dim_shape = tf.shape(X)[-1]
          input_dim = tf.convert_to_tensor(self.input_dim, dtype=settings.int_type)
          with tf.control_dependencies([tf.assert_equal(input_dim_shape, input_dim)]):
              X = tf.identity(X)
  
          return X, X2