code: def get_num_hops(model: torch.nn.Module) -> int:
      r"""Returns the number of hops the model is aggregating information
      from.
  
      .. note::
  
          This function counts the number of message passing layers as an
          approximation of the total number of hops covered by the model.
          Its output may not necessarily be correct in case message passing
          layers perform multi-hop aggregation, *e.g.*, as in
          :class:`~torch_geometric.nn.conv.ChebConv`.
  
      Example:
          >>> class GNN(torch.nn.Module):
          ...     def __init__(self):
          ...         super().__init__()
          ...         self.conv1 = GCNConv(3, 16)
          ...         self.conv2 = GCNConv(16, 16)
          ...         self.lin = Linear(16, 2)
          ...
          ...     def forward(self, x, edge_index):
          ...         x = self.conv1(x, edge_index).relu()
          ...         x = self.conv2(x, edge_index).relu()
          ...         return self.lin(x)
          >>> get_num_hops(GNN())
          2
      """
      from torch_geometric.nn.conv import MessagePassing
  
      num_hops = 0
      for module in model.modules():
          if isinstance(module, MessagePassing):
              num_hops += 1
      return num_hops
  
file_path: pytorch_geometric/torch_geometric/utils/_subgraph.py
imports: from typing import List, Literal, Optional, Tuple, Union, overload
  import torch
  from torch import Tensor
  from torch_geometric.typing import OptTensor, PairTensor
  from torch_geometric.utils import scatter
  from torch_geometric.utils.map import map_index
  from torch_geometric.utils.mask import index_to_mask
  from torch_geometric.utils.num_nodes import maybe_num_nodes
label_desc: Use image node_id 1 for calling a global function with example usage: get_num_hops(model) and returns: num_hops