code: def calculate_weights_indices(
      in_length, out_length, scale, kernel, kernel_width, antialiasing
  ):
      if (scale < 1) and (antialiasing):
          # Use a modified kernel to simultaneously interpolate and antialias- larger kernel width
          kernel_width = kernel_width / scale
  
      # Output-space coordinates
      x = torch.linspace(1, out_length, out_length)
  
      # Input-space coordinates. Calculate the inverse mapping such that 0.5
      # in output space maps to 0.5 in input space, and 0.5+scale in output
      # space maps to 1.5 in input space.
      u = x / scale + 0.5 * (1 - 1 / scale)
  
      # What is the left-most pixel that can be involved in the computation?
      left = torch.floor(u - kernel_width / 2)
  
      # What is the maximum number of pixels that can be involved in the
      # computation?  Note: it's OK to use an extra pixel here; if the
      # corresponding weights are all zero, it will be eliminated at the end
      # of this function.
      P = math.ceil(kernel_width) + 2
  
      # The indices of the input pixels involved in computing the k-th output
      # pixel are in row k of the indices matrix.
      indices = left.view(out_length, 1).expand(
          out_length, P
      ) + torch.linspace(0, P - 1, P).view(1, P).expand(out_length, P)
  
      # The weights used to compute the k-th output pixel are in row k of the
      # weights matrix.
      distance_to_center = (
          u.view(out_length, 1).expand(out_length, P) - indices
      )
      # apply cubic kernel
      if (scale < 1) and (antialiasing):
          weights = scale * cubic(distance_to_center * scale)
      else:
          weights = cubic(distance_to_center)
      # Normalize the weights matrix so that each row sums to 1.
      weights_sum = torch.sum(weights, 1).view(out_length, 1)
      weights = weights / weights_sum.expand(out_length, P)
  
      # If a column in weights is all zero, get rid of it. only consider the first and last column.
      weights_zero_tmp = torch.sum((weights == 0), 0)
      if not math.isclose(weights_zero_tmp[0], 0, rel_tol=1e-6):
          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-6):
          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)
  
imports: import math
  import os
  import random
  from datetime import datetime
  import cv2
  import numpy
  import torch
  from torchvision.utils import make_grid
label_desc: Use image node_id 47 for calling a global function with example usage: calculate_weights_indices(in_length, out_length, scale, kernel, kernel_width, antialiasing) and returns: weights,  indices,  int,  int