class_docstr: The `MixtureSameFamily` distribution implements a (batch of) mixture
  distribution where all component are from different parameterizations of
  the same distribution type. It is parameterized by a `Categorical`
  "selecting distribution" (over `k` component) and a component
  distribution, i.e., a `Distribution` with a rightmost batch shape
  (equal to `[k]`) which indexes each (batch of) component.
  
  Examples::
  
      >>> # xdoctest: +SKIP("undefined vars")
      >>> # Construct Gaussian Mixture Model in 1D consisting of 5 equally
      >>> # weighted normal distributions
      >>> mix = D.Categorical(torch.ones(5,))
      >>> comp = D.Normal(torch.randn(5,), torch.rand(5,))
      >>> gmm = MixtureSameFamily(mix, comp)
  
      >>> # Construct Gaussian Mixture Model in 2D consisting of 5 equally
      >>> # weighted bivariate normal distributions
      >>> mix = D.Categorical(torch.ones(5,))
      >>> comp = D.Independent(D.Normal(
      ...          torch.randn(5,2), torch.rand(5,2)), 1)
      >>> gmm = MixtureSameFamily(mix, comp)
  
      >>> # Construct a batch of 3 Gaussian Mixture Models in 2D each
      >>> # consisting of 5 random weighted bivariate normal distributions
      >>> mix = D.Categorical(torch.rand(3,5))
      >>> comp = D.Independent(D.Normal(
      ...         torch.randn(3,5,2), torch.rand(3,5,2)), 1)
      >>> gmm = MixtureSameFamily(mix, comp)
  
  Args:
      mixture_distribution: `torch.distributions.Categorical`-like
          instance. Manages the probability of selecting component.
          The number of categories must match the rightmost batch
          dimension of the `component_distribution`. Must have either
          scalar `batch_shape` or `batch_shape` matching
          `component_distribution.batch_shape[:-1]`
      component_distribution: `torch.distributions.Distribution`-like
          instance. Right-most batch dimension indexes component.
class_docstr_tok: ["The","`","MixtureSameFamily","`","distribution","implements","a","(","batch","of",")","mixture","distribution","where","all","component","are","from","different","parameterizations","of","the","same","distribution","type",".","It","is","parameterized","by","a","`","Categorical","`","''","selecting","distribution","''","(","over","`","k","`","component",")","and","a","component","distribution",",","i.e.",",","a","`","Distribution","`","with","a","rightmost","batch","shape","(","equal","to","`","[","k","]","`",")","which","indexes","each","(","batch","of",")","component",".","Examples",":",":",">",">",">","#","xdoctest",":","+SKIP","(","``","undefined","vars","''",")",">",">",">","#","Construct","Gaussian","Mixture","Model","in","1D","consisting","of","5","equally",">",">",">","#","weighted","normal","distributions",">",">",">","mix","=","D.Categorical","(","torch.ones","(","5",",",")",")",">",">",">","comp","=","D.Normal","(","torch.randn","(","5",",",")",",","torch.rand","(","5",",",")",")",">",">",">","gmm","=","MixtureSameFamily","(","mix",",","comp",")",">",">",">","#","Construct","Gaussian","Mixture","Model","in","2D","consisting","of","5","equally",">",">",">","#","weighted","bivariate","normal","distributions",">",">",">","mix","=","D.Categorical","(","torch.ones","(","5",",",")",")",">",">",">","comp","=","D.Independent","(","D.Normal","(","...","torch.randn","(","5,2",")",",","torch.rand","(","5,2",")",")",",","1",")",">",">",">","gmm","=","MixtureSameFamily","(","mix",",","comp",")",">",">",">","#","Construct","a","batch","of","3","Gaussian","Mixture","Models","in","2D","each",">",">",">","#","consisting","of","5","random","weighted","bivariate","normal","distributions",">",">",">","mix","=","D.Categorical","(","torch.rand","(","3,5",")",")",">",">",">","comp","=","D.Independent","(","D.Normal","(","...","torch.randn","(","3,5,2",")",",","torch.rand","(","3,5,2",")",")",",","1",")",">",">",">","gmm","=","MixtureSameFamily","(","mix",",","comp",")","Args",":","mixture_distribution",":","`","torch.distributions.Categorical","`","-like","instance",".","Manages","the","probability","of","selecting","component",".","The","number","of","categories","must","match","the","rightmost","batch","dimension","of","the","`","component_distribution","`",".","Must","have","either","scalar","`","batch_shape","`","or","`","batch_shape","`","matching","`","component_distribution.batch_shape","[",":","-1","]","`","component_distribution",":","`","torch.distributions.Distribution","`","-like","instance",".","Right-most","batch","dimension","indexes","component","."]
code: def _pad(self, x):
      return x.unsqueeze(-1 - self._event_ndims)
  
file_path: pytorch/torch/distributions/mixture_same_family.py
imports: from typing import Dict
  import torch
  from torch.distributions import Categorical, constraints
  from torch.distributions.distribution import Distribution
label_desc: Use image node_id 11 for calling the MixtureSameFamily obj's underlying member method code with example usage: obj._pad(x) and returns: x