Applying Function to Specific Tensor Elements with GPU Parallelization

Hello, I have a set of values in a tensor and I want to apply a function that takes in several values and returns a value based on those. Basically, multiple elements as input to each output tensor element. I have attached an image of what I am trying to do. I want to take advantage of GPU parallelization as much as possible.