import torch


def reppoints_head__points2bbox(ctx, self, pts, y_first=True):
    """Rewrite of `points2bbox` in `RepPointsHead`.

    Use `self.moment_transfer` in `points2bbox` will cause error:
    RuntimeError: Input, output and indices must be on the current device
    """
    moment_transfer = self.moment_transfer
    delattr(self, 'moment_transfer')
    self.moment_transfer = torch.tensor(moment_transfer.data)
    ret = ctx.origin_func(self, pts, y_first=y_first)
    self.moment_transfer = moment_transfer
    return ret