code: def _(d, batch_shape):
      init_dist = reshape_batch(d.initial_dist, batch_shape)
      trans_mat = d.transition_matrix.reshape(
          batch_shape + (-1, d.hidden_dim, d.hidden_dim)
      )
      trans_dist = reshape_batch(d.transition_dist, batch_shape + (-1,))
      obs_mat = d.observation_matrix.reshape(
          batch_shape + (-1, d.hidden_dim, d.obs_dim)
      )
      obs_dist = reshape_batch(d.observation_dist, batch_shape + (-1,))
  
      new = d._get_checked_instance(dist.LinearHMM)
      new.hidden_dim = d.hidden_dim
      new.obs_dim = d.obs_dim
      new.initial_dist = init_dist
      new.transition_matrix = trans_mat
      new.transition_dist = trans_dist
      new.observation_matrix = obs_mat
      new.observation_dist = obs_dist
      transforms = []
      for transform in d.transforms:
          assert type(transform) in UNIVARIATE_TRANSFORMS, (
              "Currently, reshape_batch only supports AbsTransform, "
              + "ExpTransform, SigmoidTransform transform"
          )
          old_shape = d.observation_dist.shape()
          new_shape = obs_dist.shape()
          transforms.append(
              reshape_transform_batch(transform, old_shape, new_shape)
          )
      new.transforms = transforms
      super(dist.LinearHMM, new).__init__(
          d.duration,
          batch_shape,
          d.event_shape,
          validate_args=d._validate_args,
      )
      return new
  
imports: import numbers
  from functools import singledispatch
  import torch
  from torch.distributions import transform_to, transforms
  import pyro.distributions
  from pyro.infer.reparam import DiscreteCosineReparam, HaarReparam
  from pyro.poutine.messenger import Messenger
  from pyro.poutine.util import site_is_subsample
  from pyro.primitives import get_param_store
label_desc: Use image node_id 20 for calling a global function with example usage: _(d, batch_shape) and returns: new