def calculate_weights_indices(in_length, out_length, scale, kernel, kernel_width, antialiasing):
    if ((scale < 1) and antialiasing):
        kernel_width = (kernel_width / scale)
    x = torch.linspace(1, out_length, out_length)
    u = ((x / scale) + (0.5 * (1 - (1 / scale))))
    left = torch.floor((u - (kernel_width / 2)))
    P = (math.ceil(kernel_width) + 2)
    indices = (left.view(out_length, 1).expand(out_length, P) + torch.linspace(0, (P - 1), P).view(1, P).expand(out_length, P))
    distance_to_center = (u.view(out_length, 1).expand(out_length, P) - indices)
    if ((scale < 1) and antialiasing):
        weights = (scale * kernel((distance_to_center * scale)))
    else:
        weights = kernel(distance_to_center)
    weights_sum = torch.sum(weights, 1).view(out_length, 1)
    weights = (weights / weights_sum.expand(out_length, P))
    weights_zero_tmp = torch.sum((weights == 0), 0)
    if (not math.isclose(weights_zero_tmp[0], 0, rel_tol=1e-06)):
        indices = indices.narrow(1, 1, (P - 2))
        weights = weights.narrow(1, 1, (P - 2))
    if (not math.isclose(weights_zero_tmp[(- 1)], 0, rel_tol=1e-06)):
        indices = indices.narrow(1, 0, (P - 2))
        weights = weights.narrow(1, 0, (P - 2))
    weights = weights.contiguous()
    indices = indices.contiguous()
    sym_len_s = ((- indices.min()) + 1)
    sym_len_e = (indices.max() - in_length)
    indices = ((indices + sym_len_s) - 1)
    return (weights, indices, int(sym_len_s), int(sym_len_e))
def calculate_weights_indices(in_length, out_length, scale, kernel, kernel_width, antialiasing):
    if ((scale < 1) and antialiasing):
        kernel_width = (kernel_width / scale)
    x = torch.linspace(1, out_length, out_length)
    u = ((x / scale) + (0.5 * (1 - (1 / scale))))
    left = torch.floor((u - (kernel_width / 2)))
    P = (math.ceil(kernel_width) + 2)
    indices = (left.view(out_length, 1).expand(out_length, P) + torch.linspace(0, (P - 1), P).view(1, P).expand(out_length, P))
    distance_to_center = (u.view(out_length, 1).expand(out_length, P) - indices)
    if ((scale < 1) and antialiasing):
        weights = (scale * kernel((distance_to_center * scale)))
    else:
        weights = kernel(distance_to_center)
    weights_sum = torch.sum(weights, 1).view(out_length, 1)
    weights = (weights / weights_sum.expand(out_length, P))
    weights_zero_tmp = torch.sum((weights == 0), 0)
    if (not math.isclose(weights_zero_tmp[0], 0, rel_tol=1e-06)):
        indices = indices.narrow(1, 1, (P - 2))
        weights = weights.narrow(1, 1, (P - 2))
    if (not math.isclose(weights_zero_tmp[(- 1)], 0, rel_tol=1e-06)):
        indices = indices.narrow(1, 0, (P - 2))
        weights = weights.narrow(1, 0, (P - 2))
    weights = weights.contiguous()
    indices = indices.contiguous()
    sym_len_s = ((- indices.min()) + 1)
    sym_len_e = (indices.max() - in_length)
    indices = ((indices + sym_len_s) - 1)
    return (weights, indices, int(sym_len_s), int(sym_len_e))