class_docstr: The basic kernel class. Management of active dimensions is implemented here.
  
  :param active_dims: active dimensions, either a slice or list of
      indices into the columns of X.
  :param name: optional kernel name.
class_docstr_tok: ["The","basic","kernel","class",".","Management","of","active","dimensions","is","implemented","here",".",":","param","active_dims",":","active","dimensions",",","either","a","slice","or","list","of","indices","into","the","columns","of","X.",":","param","name",":","optional","kernel","name","."]
docstr: Slice the correct dimensions for use in the kernel, as indicated by
  `self.active_dims` for covariance matrices. This requires slicing the
  rows *and* columns. This will also turn flattened diagonal
  matrices into a tensor of full diagonal matrices.
  
  :param cov: Tensor of covariance matrices.
  :return: Sliced covariance matrices.
docstr_tok: ["Slice","the","correct","dimensions","for","use","in","the","kernel",",","as","indicated","by","`","self.active_dims","`","for","covariance","matrices",".","This","requires","slicing","the","rows","*","and","*","columns",".","This","will","also","turn","flattened","diagonal","matrices","into","a","tensor","of","full","diagonal","matrices",".",":","param","cov",":","Tensor","of","covariance","matrices",".",":","return",":","Sliced","covariance","matrices","."]
code: def slice_cov(self, cov: TensorType) -> tf.Tensor:
      """
      Slice the correct dimensions for use in the kernel, as indicated by
      `self.active_dims` for covariance matrices. This requires slicing the
      rows *and* columns. This will also turn flattened diagonal
      matrices into a tensor of full diagonal matrices.
  
      :param cov: Tensor of covariance matrices.
      :return: Sliced covariance matrices.
      """
      cov = tf.convert_to_tensor(cov)
      assert isinstance(cov, tf.Tensor)  # Hint for mypy.
  
      if cov.shape.ndims == 2:
          cov = tf.linalg.diag(cov)
  
      dims = self.active_dims
  
      if isinstance(dims, slice):
          return cov[..., dims, dims]
      elif dims is not None:
          nlast = tf.shape(cov)[-1]
          ndims = len(dims)
  
          cov_shape = tf.shape(cov)
          cov_reshaped = tf.reshape(cov, [-1, nlast, nlast])
          gather1 = tf.gather(
              tf.transpose(cov_reshaped, [2, 1, 0]), dims
          )
          gather2 = tf.gather(tf.transpose(gather1, [1, 0, 2]), dims)
          cov = tf.reshape(
              tf.transpose(gather2, [2, 0, 1]),
              tf.concat([cov_shape[:-2], [ndims, ndims]], 0),
          )
  
      return cov
  
imports: import abc
  from functools import partial, reduce
  from typing import Callable, List, Optional, Sequence, Tuple, Union, overload
  import numpy
  import tensorflow
  from check_shapes import check_shapes
  from ..base import AnyNDArray, Module, TensorType
label_desc: Use image node_id 9 for calling the Kernel obj's underlying member method code with example usage: obj.slice_cov(cov) and returns: cov, cov