code: def grid_sample_padding(
      grid, padding_mode, align_corners, borders=None
  ):
      if padding_mode == "reflection":
          if align_corners:
              for idx, border in enumerate(borders):
                  grid[..., idx] = reflect(
                      grid[..., idx], 0, 2 * (border - 1)
                  )
                  grid[..., idx] = ivy.clip(
                      grid[..., idx], 0, border - 1
                  )
  
          else:
              for idx, border in enumerate(borders):
                  grid[..., idx] = reflect(
                      grid[..., idx], -1, 2 * border - 1
                  )
                  grid[..., idx] = ivy.clip(
                      grid[..., idx], 0, border - 1
                  )
  
      elif padding_mode == "border":
          for idx, border in enumerate(borders):
              grid[..., idx] = ivy.clip(grid[..., idx], 0, border - 1)
  
      masks = []
      for idx, border in enumerate(borders):
          masks.append(
              ivy.bitwise_or(
                  grid[..., idx] < -4, grid[..., idx] > border + 2
              )
          )
          borders[idx] += 1
  
      zeros_mask = masks[0]
      for i in range(1, len(borders)):
          zeros_mask = ivy.bitwise_or(zeros_mask, masks[i])
  
      if grid[zeros_mask].shape[0] > 0:
          grid[zeros_mask] = ivy.array(borders)
      return grid
  
file_path: ivy/ivy/functional/frontends/torch/nn/functional/vision_functions.py
imports: import ivy
  from ivy import with_unsupported_dtypes, with_supported_dtypes
  from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
label_desc: Use image node_id 7 for calling a global function with example usage: grid_sample_padding(grid, padding_mode, align_corners, borders) and returns: grid