code: def build_positional_indices(
      shape: torch.Size,
      dim: int,
      device: Optional[torch.device] = None,
  ) -> LongTensor:
      return sum(
          gen_positional_indices(shape=shape, dim=dim, device=device)
      )
  
imports: from __future__ import annotations
  import math
  from functools import lru_cache
  from math import pi
  from numbers import Number
  from typing import Any, Callable, Iterable, Iterator, Optional, Tuple, Union
  import torch
  from botorch.utils.safe_math import logdiffexp
  from numpy.polynomial.legendre import leggauss
  from torch import BoolTensor, LongTensor, Tensor
label_desc: Use image node_id 5 for calling a global function with example usage: build_positional_indices(shape, dim, device) and returns: sum