class_docstr: `FeatureScaled` kernel for continuous and embedded categorical data.
  
  This kernel is an extension of `FeatureScaled` that handles categorical data
  (encoded as integers, not one-hot) in addition to continuous (float) data.
  `ContinuousAndCategoricalValues` structures, containing arrays of continuous
  and categorical data, are passed to the `apply`, `matrix` and `tensor`
  methods. The continuous inputs are scaled and then passed to the distance
  function, like in `FeatureScaled`. Categorical data, encoded as integers,
  is continuously embedded using `LinearOperator`s. When all `LinearOperator`s
  are either `LinearOperatorIdentity` or `LinearOperatorScaledIdentity`
  instances, this kernel is the same as `FeatureScaledWithCategorical`, though
  in that case the latter should be used since it will be more efficient.
  
  #### Examples
  
  Compute the kernel matrix on synthetic data.
  
  ```python
  import numpy as np
  
  continuous_dim = 3
  categorical_dim = 2
  
  # Define an ARD kernel that takes a structure of continuous and categorical
  # data as inputs, with randomly-sampled `continuous_scale_diag` values and
  # diagonal embeddings of categorical data.
  base_kernel = tfpk.MaternFiveHalves()
  continuous_scale_diag = np.random.uniform(size=[continuous_dim])
  
  # Categorical `scale_diag`s are passed as an iterable of `LinearOperator`s,
  # where each `LinearOperator` applies to a categorical feature and has number
  # of rows equivalent to the cardinality of that feature. Categorical data is
  # assumed to be represented as integers between 0 and `n - 1` inclusive, which
  # are used to index into the `inverse_scale_diag` vectors.
  num_categories = [5, 4]
  categorical_embedding_operators = [
      tf.linalg.LinearOperatorDiag(np.random.uniform(size=[n]))
      for n in num_categories]
  
  kernel = tfpke.FeatureScaledWithEmbeddedCategorical(
      base_kernel,
      categorical_embedding_operators=categorical_embedding_operators,
      continuous_scale_diag=continuous_scale_diag,
      validate_args=True)
  
  # Create `num_points` examples in the continuous/categorical feature space.
  num_points = 12
  categorical_data_1 = np.stack(
      [np.random.randint(n, size=(num_points,)) for n in num_categories])
  categorical_data_2 = np.stack(
      [np.random.randint(n, size=(num_points,)) for n in num_categories])
  x1 = tfpke.ContinuousAndCategoricalValues(
      continuous=np.random.normal(size=(num_points, continuous_dim)),
      categorical=categorical_data_1)
  x2 = tfpke.ContinuousAndCategoricalValues(
      continuous=np.random.normal(size=(num_points, continuous_dim)),
      categorical=categorical_data_2)
  
  # Evaluate the kernel matrix for `x1` and `x2`.
  kernel.matrix(x1, x2)  # has shape `[num_points, num_points]`
  
  ```
class_docstr_tok: ["`","FeatureScaled","`","kernel","for","continuous","and","embedded","categorical","data",".","This","kernel","is","an","extension","of","`","FeatureScaled","`","that","handles","categorical","data","(","encoded","as","integers",",","not","one-hot",")","in","addition","to","continuous","(","float",")","data",".","`","ContinuousAndCategoricalValues","`","structures",",","containing","arrays","of","continuous","and","categorical","data",",","are","passed","to","the","`","apply","`",",","`","matrix","`","and","`","tensor","`","methods",".","The","continuous","inputs","are","scaled","and","then","passed","to","the","distance","function",",","like","in","`","FeatureScaled","`",".","Categorical","data",",","encoded","as","integers",",","is","continuously","embedded","using","`","LinearOperator","`","s",".","When","all","`","LinearOperator","`","s","are","either","`","LinearOperatorIdentity","`","or","`","LinearOperatorScaledIdentity","`","instances",",","this","kernel","is","the","same","as","`","FeatureScaledWithCategorical","`",",","though","in","that","case","the","latter","should","be","used","since","it","will","be","more","efficient",".","#","#","#","#","Examples","Compute","the","kernel","matrix","on","synthetic","data",".","``","`","python","import","numpy","as","np","continuous_dim","=","3","categorical_dim","=","2","#","Define","an","ARD","kernel","that","takes","a","structure","of","continuous","and","categorical","#","data","as","inputs",",","with","randomly-sampled","`","continuous_scale_diag","`","values","and","#","diagonal","embeddings","of","categorical","data",".","base_kernel","=","tfpk.MaternFiveHalves","(",")","continuous_scale_diag","=","np.random.uniform","(","size=","[","continuous_dim","]",")","#","Categorical","`","scale_diag","`","s","are","passed","as","an","iterable","of","`","LinearOperator","`","s",",","#","where","each","`","LinearOperator","`","applies","to","a","categorical","feature","and","has","number","#","of","rows","equivalent","to","the","cardinality","of","that","feature",".","Categorical","data","is","#","assumed","to","be","represented","as","integers","between","0","and","`","n","-","1","`","inclusive",",","which","#","are","used","to","index","into","the","`","inverse_scale_diag","`","vectors",".","num_categories","=","[","5",",","4","]","categorical_embedding_operators","=","[","tf.linalg.LinearOperatorDiag","(","np.random.uniform","(","size=","[","n","]",")",")","for","n","in","num_categories","]","kernel","=","tfpke.FeatureScaledWithEmbeddedCategorical","(","base_kernel",",","categorical_embedding_operators=categorical_embedding_operators",",","continuous_scale_diag=continuous_scale_diag",",","validate_args=True",")","#","Create","`","num_points","`","examples","in","the","continuous\/categorical","feature","space",".","num_points","=","12","categorical_data_1","=","np.stack","(","[","np.random.randint","(","n",",","size=","(","num_points",",",")",")","for","n","in","num_categories","]",")","categorical_data_2","=","np.stack","(","[","np.random.randint","(","n",",","size=","(","num_points",",",")",")","for","n","in","num_categories","]",")","x1","=","tfpke.ContinuousAndCategoricalValues","(","continuous=np.random.normal","(","size=","(","num_points",",","continuous_dim",")",")",",","categorical=categorical_data_1",")","x2","=","tfpke.ContinuousAndCategoricalValues","(","continuous=np.random.normal","(","size=","(","num_points",",","continuous_dim",")",")",",","categorical=categorical_data_2",")","#","Evaluate","the","kernel","matrix","for","`","x1","`","and","`","x2","`",".","kernel.matrix","(","x1",",","x2",")","#","has","shape","`","[","num_points",",","num_points","]","`","``","`"]
docstr: Construct an `FeatureScaledWithCategorical` kernel instance.
  
  Args:
    kernel: `PositiveSemidefiniteKernel` instance. Parameters to `kernel` must
      be broadcastable with `scale_diag`. `kernel` must be isotropic and
      implement an `_apply_with_distance` method.
    categorical_embedding_operators: Iterable of `LinearOperator` instances
      used to embed the categorical features. If the input categorical data
      has shape `[..., d]` and a single feature dimension, the iterable has
      length `d`.  Each `LinearOperator` has number of rows equal to the
      number of categories, and embeddings are equivalent to one-hot encoded
      categorical vectors multiplied by the densified `LinearOperator`.
      Euclidean distances are computed between the emeddings. If there are 0
      feature dimensions, the iterable should have length 1.
    continuous_scale_diag: Floating point array that control the
      sharpness/width of the kernel shape. Each `continuous_scale_diag` must
      have dimensionality of at least `kernel.feature_ndims.continuous`, and
      extra dimensions must be broadcastable with parameters of `kernel`.
      Default value: None.
    continuous_inverse_scale_diag: Non-negative floating point vectors that
      are treated as the reciprocals of the corresponding components of
      `continuous_scale_diag`.  Only one of `continuous_scale_diag` or
      `continuous_inverse_scale_diag` should be provided.
      Default value: None
    feature_ndims: `ContinuousAndCategoricalValues` instance containing
      integers indicating the rank of the continuous and categorical feature
      space. Default value: None, i.e. `kernel.feature_ndims` for both
      components of the feature space. Categorical `feature_ndims` > 1 is not
      supported.
    validate_args: If `True`, parameters are checked for validity despite
      possibly degrading runtime performance.
    name: Python `str` name prefixed to Ops created by this class.
docstr_tok: ["Construct","an","`","FeatureScaledWithCategorical","`","kernel","instance",".","Args",":","kernel",":","`","PositiveSemidefiniteKernel","`","instance",".","Parameters","to","`","kernel","`","must","be","broadcastable","with","`","scale_diag","`",".","`","kernel","`","must","be","isotropic","and","implement","an","`","_apply_with_distance","`","method",".","categorical_embedding_operators",":","Iterable","of","`","LinearOperator","`","instances","used","to","embed","the","categorical","features",".","If","the","input","categorical","data","has","shape","`","[","...",",","d","]","`","and","a","single","feature","dimension",",","the","iterable","has","length","`","d","`",".","Each","`","LinearOperator","`","has","number","of","rows","equal","to","the","number","of","categories",",","and","embeddings","are","equivalent","to","one-hot","encoded","categorical","vectors","multiplied","by","the","densified","`","LinearOperator","`",".","Euclidean","distances","are","computed","between","the","emeddings",".","If","there","are","0","feature","dimensions",",","the","iterable","should","have","length","1.","continuous_scale_diag",":","Floating","point","array","that","control","the","sharpness\/width","of","the","kernel","shape",".","Each","`","continuous_scale_diag","`","must","have","dimensionality","of","at","least","`","kernel.feature_ndims.continuous","`",",","and","extra","dimensions","must","be","broadcastable","with","parameters","of","`","kernel","`",".","Default","value",":","None",".","continuous_inverse_scale_diag",":","Non-negative","floating","point","vectors","that","are","treated","as","the","reciprocals","of","the","corresponding","components","of","`","continuous_scale_diag","`",".","Only","one","of","`","continuous_scale_diag","`","or","`","continuous_inverse_scale_diag","`","should","be","provided",".","Default","value",":","None","feature_ndims",":","`","ContinuousAndCategoricalValues","`","instance","containing","integers","indicating","the","rank","of","the","continuous","and","categorical","feature","space",".","Default","value",":","None",",","i.e",".","`","kernel.feature_ndims","`","for","both","components","of","the","feature","space",".","Categorical","`","feature_ndims","`",">","1","is","not","supported",".","validate_args",":","If","`","True","`",",","parameters","are","checked","for","validity","despite","possibly","degrading","runtime","performance",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","class","."]
code: def __init__(
      self,
      kernel,
      categorical_embedding_operators,
      continuous_scale_diag=None,
      continuous_inverse_scale_diag=None,
      feature_ndims=None,
      validate_args=False,
      name="FeatureScaledWithCategorical",
  ):
      """Construct an `FeatureScaledWithCategorical` kernel instance.
  
      Args:
        kernel: `PositiveSemidefiniteKernel` instance. Parameters to `kernel` must
          be broadcastable with `scale_diag`. `kernel` must be isotropic and
          implement an `_apply_with_distance` method.
        categorical_embedding_operators: Iterable of `LinearOperator` instances
          used to embed the categorical features. If the input categorical data
          has shape `[..., d]` and a single feature dimension, the iterable has
          length `d`.  Each `LinearOperator` has number of rows equal to the
          number of categories, and embeddings are equivalent to one-hot encoded
          categorical vectors multiplied by the densified `LinearOperator`.
          Euclidean distances are computed between the emeddings. If there are 0
          feature dimensions, the iterable should have length 1.
        continuous_scale_diag: Floating point array that control the
          sharpness/width of the kernel shape. Each `continuous_scale_diag` must
          have dimensionality of at least `kernel.feature_ndims.continuous`, and
          extra dimensions must be broadcastable with parameters of `kernel`.
          Default value: None.
        continuous_inverse_scale_diag: Non-negative floating point vectors that
          are treated as the reciprocals of the corresponding components of
          `continuous_scale_diag`.  Only one of `continuous_scale_diag` or
          `continuous_inverse_scale_diag` should be provided.
          Default value: None
        feature_ndims: `ContinuousAndCategoricalValues` instance containing
          integers indicating the rank of the continuous and categorical feature
          space. Default value: None, i.e. `kernel.feature_ndims` for both
          components of the feature space. Categorical `feature_ndims` > 1 is not
          supported.
        validate_args: If `True`, parameters are checked for validity despite
          possibly degrading runtime performance.
        name: Python `str` name prefixed to Ops created by this class.
      """
      parameters = dict(locals())
      if (continuous_scale_diag is None) == (
          continuous_inverse_scale_diag is None
      ):
          raise ValueError(
              "Must specify exactly one of `continuous_scale_diag` and "
              "`continuous_inverse_scale_diag`."
          )
      with tf.name_scope(name):
          float_dtype = dtype_util.common_dtype(
              [
                  kernel,
                  continuous_scale_diag,
                  continuous_inverse_scale_diag,
                  categorical_embedding_operators,
              ],
              dtype_hint=tf.float32,
          )
          if continuous_scale_diag is None:
              self._continuous_scale_diag = continuous_scale_diag
              self._continuous_inverse_scale_diag = (
                  tensor_util.convert_nonref_to_tensor(
                      continuous_inverse_scale_diag,
                      dtype_hint=float_dtype,
                      name="continuous_inverse_scale_diag",
                  )
              )
          else:
              self._continuous_inverse_scale_diag = (
                  continuous_inverse_scale_diag
              )
              self._continuous_scale_diag = (
                  tensor_util.convert_nonref_to_tensor(
                      continuous_scale_diag,
                      dtype_hint=float_dtype,
                      name="continuous_scale_diag",
                  )
              )
          self._categorical_embedding_operators = (
              categorical_embedding_operators
          )
          self._kernel = kernel
  
          if feature_ndims is None:
              feature_ndims = fswc.ContinuousAndCategoricalValues(
                  kernel.feature_ndims, kernel.feature_ndims
              )
          if feature_ndims.categorical > 1:
              raise ValueError(
                  "Categorical `feature_ndims` must be 0 or 1."
              )
  
          dtype = fswc.ContinuousAndCategoricalValues(float_dtype, None)
          super(FeatureScaledWithEmbeddedCategorical, self).__init__(
              feature_ndims=feature_ndims,
              dtype=dtype,
              name=name,
              validate_args=validate_args,
              parameters=parameters,
          )
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.psd_kernels import feature_scaled_with_categorical
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math.psd_kernels import positive_semidefinite_kernel
  from tensorflow_probability.python.math.psd_kernels.internal import util
label_desc: Use image node_id 1 to create a new FeatureScaledWithEmbeddedCategorical object from inherited base classes: psd_kernel with example: obj = FeatureScaledWithEmbeddedCategorical(kernel, categorical_embedding_operators, continuous_scale_diag, continuous_inverse_scale_diag, feature_ndims, validate_args, name)