code: def filter_valids(tensor, valids):
      """Filter out tensor using valids (last index of valid tensors).
  
      valids contains last indices of each rows.
  
      Args:
          tensor (torch.Tensor): The tensor to filter
          valids (list[int]): Array of length of the valid values
  
      Returns:
          torch.Tensor: Filtered Tensor
  
      """
      return [tensor[i][:valid] for i, valid in enumerate(valids)]
  
imports: import copy
  import math
  import warnings
  import torch
  from torch import nn
  import torch.nn.functional
label_desc: Use image node_id 4 for calling a global function with example usage: filter_valids(tensor, valids) and returns: unknown