def METHOD_NAME(max):
    if not hasattr(METHOD_NAME, "buf"):
        METHOD_NAME.buf = torch.LongTensor()
    if max > METHOD_NAME.buf.numel():
        METHOD_NAME.buf.resize_(max)
        torch.arange(max, out=METHOD_NAME.buf)
    return METHOD_NAME.buf[:max]