class_docstr: Mixin to provide Pyro compatibility for PyTorch distributions.
  
  You should instead use `TorchDistribution` for new distribution classes.
  
  This is mainly useful for wrapping existing PyTorch distributions for
  use in Pyro.  Derived classes must first inherit from
  :class:`torch.distributions.distribution.Distribution` and then inherit
  from :class:`TorchDistributionMixin`.
class_docstr_tok: ["Mixin","to","provide","Pyro","compatibility","for","PyTorch","distributions",".","You","should","instead","use","`","TorchDistribution","`","for","new","distribution","classes",".","This","is","mainly","useful","for","wrapping","existing","PyTorch","distributions","for","use","in","Pyro",".","Derived","classes","must","first","inherit","from",":","class",":","`","torch.distributions.distribution.Distribution","`","and","then","inherit","from",":","class",":","`","TorchDistributionMixin","`","."]
docstr: Expands a distribution by adding ``sample_shape`` to the left side of
  its :attr:`~torch.distributions.distribution.Distribution.batch_shape`.
  
  To expand internal dims of ``self.batch_shape`` from 1 to something
  larger, use :meth:`expand` instead.
  
  :param torch.Size sample_shape: The size of the iid batch to be drawn
      from the distribution.
  :return: An expanded version of this distribution.
  :rtype: :class:`ExpandedDistribution`
code: def expand_by(self, sample_shape):
      """
      Expands a distribution by adding ``sample_shape`` to the left side of
      its :attr:`~torch.distributions.distribution.Distribution.batch_shape`.
  
      To expand internal dims of ``self.batch_shape`` from 1 to something
      larger, use :meth:`expand` instead.
  
      :param torch.Size sample_shape: The size of the iid batch to be drawn
          from the distribution.
      :return: An expanded version of this distribution.
      :rtype: :class:`ExpandedDistribution`
      """
      try:
          expanded_dist = self.expand(
              torch.Size(sample_shape) + self.batch_shape
          )
      except NotImplementedError:
          expanded_dist = TorchDistributionMixin.expand(
              self, torch.Size(sample_shape) + self.batch_shape
          )
      return expanded_dist
  
imports: import warnings
  from collections import OrderedDict
  from typing import Callable
  import torch
  from torch.distributions.kl import kl_divergence, register_kl
  import pyro.distributions.torch
  from .None import constraints
  from .distribution import Distribution
  from .score_parts import ScoreParts
  from .util import broadcast_shape, scale_and_mask
label_desc: Use image node_id 8 for calling the TorchDistributionMixin obj's underlying member method code with example usage: obj.expand_by(sample_shape) and returns: expanded_dist