code: def gather(value, index, dim):
      """
      Packed broadcasted gather of indexed values along a named dim.
      """
      assert dim in value._pyro_dims
      assert dim not in index._pyro_dims
      value, index = broadcast_all(value, index)
      dims = value._pyro_dims.replace(dim, "")
      pos = value._pyro_dims.index(dim)
      with ignore_jit_warnings():
          zero = torch.zeros(1, dtype=torch.long, device=index.device)
      index = index.index_select(pos, zero)
      value = value.gather(pos, index).squeeze(pos)
      value._pyro_dims = dims
      assert value.dim() == len(value._pyro_dims)
      return value
  
file_path: pyro/pyro/ops/packed.py
imports: import math
  import torch
  from pyro.distributions.util import is_identically_one
  from pyro.util import ignore_jit_warnings
label_desc: Use image node_id 4 for calling a global function with example usage: gather(value, index, dim) and returns: value