code: def sparse_cross_entropy(
      inputs: Tensor,
      edge_label_index: Tensor,
      edge_label_weight: Optional[Tensor] = None,
  ) -> Tensor:
      r"""A sparse-label variant of :func:`torch.nn.functional.cross_entropy`.
      In particular, the binary target matrix is solely given by sparse indices
      :obj:`edge_label_index`.
  
      Args:
          inputs (torch.Tensor): The predicted unnormalized logits of shape
              :obj:`[batch_size, num_classes]`.
          edge_label_index (torch.Tensor): The sparse ground-truth indices with
              shape :obj:`[2, num_labels]`.
          edge_label_weight (torch.Tensor, optional): The weight of ground-truth
              indices with shape :obj:`[num_labels]`. (default: :obj:`None`)
  
      :rtype: :class:`torch.Tensor`
  
      Example:
          >>> inputs = torch.randn(2, 3)
          >>> edge_label_index = torch.tensor([
          ...     [0, 0, 1],
          ...     [0, 1, 2],
          ... ])
          >>> loss = sparse_cross_entropy(inputs, edge_label_index)
          tensor(1.2919)
      """
      if edge_label_weight is not None:
          assert not edge_label_weight.requires_grad
  
      return SparseCrossEntropy.apply(
          inputs,
          edge_label_index,
          edge_label_weight,
      )
  
file_path: pytorch_geometric/torch_geometric/utils/cross_entropy.py
imports: from typing import Any, Optional, Tuple
  import torch
  from torch import Tensor
  from torch_geometric.utils import scatter
label_desc: Use image node_id 1 for calling a global function with example usage: sparse_cross_entropy(inputs, edge_label_index, edge_label_weight) and returns: SparseCrossEntropy