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: Infers ``batch_shape`` and ``event_shape`` given shapes of args to
  :meth:`__init__`.
  
  .. note:: This assumes distribution shape depends only on the shapes
      of tensor inputs, not in the data contained in those inputs.
  
  :param \*\*arg_shapes: Keywords mapping name of input arg to
      :class:`torch.Size` or tuple representing the sizes of each
      tensor input.
  :returns: A pair ``(batch_shape, event_shape)`` of the shapes of a
      distribution that would be created with input args of the given
      shapes.
  :rtype: tuple
code: def infer_shapes(cls, **arg_shapes):
      r"""
      Infers ``batch_shape`` and ``event_shape`` given shapes of args to
      :meth:`__init__`.
  
      .. note:: This assumes distribution shape depends only on the shapes
          of tensor inputs, not in the data contained in those inputs.
  
      :param \*\*arg_shapes: Keywords mapping name of input arg to
          :class:`torch.Size` or tuple representing the sizes of each
          tensor input.
      :returns: A pair ``(batch_shape, event_shape)`` of the shapes of a
          distribution that would be created with input args of the given
          shapes.
      :rtype: tuple
      """
      if cls.support.event_dim > 0:
          raise NotImplementedError
      # Assumes distribution is univariate.
      batch_shapes = []
      for name, shape in arg_shapes.items():
          event_dim = cls.arg_constraints.get(
              name, constraints.real
          ).event_dim
          batch_shapes.append(shape[: len(shape) - event_dim])
      batch_shape = torch.Size(broadcast_shape(*batch_shapes))
      event_shape = torch.Size()
      return batch_shape, event_shape
  
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 6 for calling the TorchDistributionMixin obj's underlying member method code with example usage: obj.infer_shapes(cls) and returns: batch_shape,  event_shape