code: def _to_edge_mask(edge_index: Tensor) -> Tensor:
      num_edges = edge_index.shape[1]
      return torch.ones(
          num_edges, requires_grad=True, device=edge_index.device
      )
  
imports: from enum import Enum
  from typing import Dict, Optional, Tuple, Union
  import torch
  from torch import Tensor
  from torch_geometric.explain.algorithm.utils import clear_masks, set_hetero_masks, set_masks
  from torch_geometric.explain.config import ModelConfig, ModelMode, ModelReturnType
  from torch_geometric.typing import EdgeType, Metadata, NodeType
label_desc: Use image node_id 1 for calling a global function with example usage: _to_edge_mask(edge_index) and returns: torch