old_contents: import torch
  import function_factory
  from torch.autograd import Variable
  from .interpolation import Interpolation
  from .lincg import LinearCG
  from .lanczos_quadrature import StochasticLQ
  
  
  def reverse(input, dim=0):
      """
      Reverses a tensor
      Args:
          - input: tensor to reverse
          - dim: dimension to reverse on
      Returns:
          - reversed input
      """
      reverse_index = torch.LongTensor(list(range(input.size(dim))[::-1]))
      return input.index_select(dim, reverse_index)
  
  
  def rcumsum(input, dim=0):
      """
      Computes a reverse cumulative sum
      Args:
          - input: tensor
          - dim: dimension to reverse on
      Returns:
          - rcumsum on input
      """
      reverse_index = torch.LongTensor(list(range(input.size(dim))[::-1]))
      return torch.index_select(input, dim, reverse_index).cumsum(dim).index_select(dim, reverse_index)
  
  
  def approx_equal(self, other, epsilon=1e-4):
      """
      Determines if two tensors are approximately equal
      Args:
          - self: tensor
          - other: tensor
      Returns:
          - bool
      """
      if isinstance(self, Variable):
          self = self.data
      if isinstance(other, Variable):
          other = other.data
      return torch.max((self - other).abs()) <= epsilon
  
  
  __all__ = [
      Interpolation,
      LinearCG,
      StochasticLQ,
      reverse,
      rcumsum,
      approx_equal,
      function_factory,
  ]
  
new_contents: import torch
  from torch.autograd import Variable
  from .interpolation import Interpolation
  from .lincg import LinearCG
  from .lanczos_quadrature import StochasticLQ
  
  
  def reverse(input, dim=0):
      """
      Reverses a tensor
      Args:
          - input: tensor to reverse
          - dim: dimension to reverse on
      Returns:
          - reversed input
      """
      reverse_index = torch.LongTensor(list(range(input.size(dim))[::-1]))
      return input.index_select(dim, reverse_index)
  
  
  def rcumsum(input, dim=0):
      """
      Computes a reverse cumulative sum
      Args:
          - input: tensor
          - dim: dimension to reverse on
      Returns:
          - rcumsum on input
      """
      reverse_index = torch.LongTensor(list(range(input.size(dim))[::-1]))
      return torch.index_select(input, dim, reverse_index).cumsum(dim).index_select(dim, reverse_index)
  
  
  def approx_equal(self, other, epsilon=1e-4):
      """
      Determines if two tensors are approximately equal
      Args:
          - self: tensor
          - other: tensor
      Returns:
          - bool
      """
      if isinstance(self, Variable):
          self = self.data
      if isinstance(other, Variable):
          other = other.data
      return torch.max((self - other).abs()) <= epsilon
  
  
  __all__ = [
      Interpolation,
      LinearCG,
      StochasticLQ,
      reverse,
      rcumsum,
      approx_equal,
  ]
  
subject: Fix python 3 compatability