code: def get_latest_k_edge_attr(
      k: int,
      edge_index: Tensor,
      edge_attr: Tensor,
      edge_time: Tensor,
      num_nodes: int,
      is_sorted: bool = False,
  ) -> Tensor:
      r"""Returns the latest :obj:`k` incoming edge attributes by
      :obj:`edge_time` for each node.
      The shape of the output tensor is :obj:`[num_nodes, k, edge_attr_dim]`.
      Nodes with fewer than :obj:`k` incoming edges are zero-padded.
      """
      _, col = edge_index
  
      if not is_sorted:
          perm = np.lexsort(
              [
                  -edge_time.detach().cpu().numpy(),
                  col.detach().cpu().numpy(),
              ]
          )
          perm = torch.from_numpy(perm).to(edge_index.device)
          col = col[perm]
          edge_attr = edge_attr[perm]
  
      return to_dense_batch(
          edge_attr,
          col,
          max_num_nodes=k,
          batch_size=num_nodes,
      )[0]
  
imports: import numpy
  import torch
  import torch.nn.functional
  from torch import Tensor
  from torch.nn import LayerNorm, Linear
  from torch_geometric.nn import TemporalEncoding
  from torch_geometric.utils import scatter, to_dense_batch
label_desc: Use image node_id 1 for calling a global function with example usage: get_latest_k_edge_attr(k, edge_index, edge_attr, edge_time, num_nodes, is_sorted) and returns: to_dense_batch