code: def _pad_with_singletons(
      obj: torch.Tensor,
      num_singletons_before: int = 0,
      num_singletons_after: int = 0,
  ):
      """
      Pad obj with singleton dimensions on the left and right
  
      Example:
          >>> x = torch.randn(10, 5)
          >>> _pad_width_singletons(x, 2, 3).shape
          >>> # [1, 1, 10, 5, 1, 1, 1]
      """
      new_shape = (
          [1] * num_singletons_before
          + list(obj.shape)
          + [1] * num_singletons_after
      )
      return obj.view(*new_shape)
  
file_path: gpytorch/gpytorch/utils/quadrature.py
imports: import math
  import numpy
  import torch
  from torch.nn import Module
  from ..None import settings
label_desc: Use image node_id 1 for calling a global function with example usage: _pad_with_singletons(obj, num_singletons_before, num_singletons_after) and returns: obj