code: def _get_source_destination_range(sampled_df):
      o = sampled_df.groupby(["batch_id", "hop_id"], as_index=True).agg(
          {"sources": "max", "destinations": "max"}
      )
      o.rename(
          columns={
              "sources": "sources_range",
              "destinations": "destinations_range",
          },
          inplace=True,
      )
      d = o.to_dict(orient="index")
      return d
  
imports: from __future__ import annotations
  from typing import List, Tuple, Dict, Optional
  from collections import defaultdict
  import cudf
  from cugraph.utilities.utils import import_optional
  from cugraph_dgl.nn import SparseGraph
label_desc: Use image node_id 3 for calling a global function with example usage: _get_source_destination_range(sampled_df) and returns: d