code: def _gather(tensor, dim, index):
      """
      Like :func:`torch.gather` but broadcasts.
      """
      if dim != -1:
          raise NotImplementedError
      shape = broadcast_shape(tensor.shape[:-1], index.shape[:-1]) + (
          -1,
      )
      tensor = tensor.expand(shape)
      index = index.expand(shape)
      return tensor.gather(dim, index)
  
imports: import functools
  import weakref
  from collections import namedtuple
  import torch
  from torch.distributions import constraints
  from pyro.distributions.util import broadcast_shape, is_validation_enabled
  from pyro.ops.special import safe_log
  from .torch_distribution import TorchDistribution
label_desc: Use image node_id 2 for calling a global function with example usage: _gather(tensor, dim, index) and returns: tensor