code: def _bucketing(val):
      """Internal function to create groups on the values.
  
      Parameters
      ----------
      val : Tensor
          Value tensor.
  
      Returns
      -------
      unique_val : Tensor
          Unique values.
      bucketor : callable[Tensor -> list[Tensor]]
          A bucketing function that splits the given tensor data as the same
          way of how the :attr:`val` tensor is grouped.
      """
      sorted_val, idx = F.sort_1d(val)
      unique_val = F.asnumpy(F.unique(sorted_val))
      bkt_idx = []
      for v in unique_val:
          eqidx = F.nonzero_1d(F.equal(sorted_val, v))
          bkt_idx.append(F.gather_row(idx, eqidx))
  
      def bucketor(data):
          bkts = [F.gather_row(data, idx) for idx in bkt_idx]
          return bkts
  
      return unique_val, bucketor
  
file_path: dgl/python/dgl/core.py
imports: import numpy
  from .None import backend, function, ops
  from .base import ALL, dgl_warning, DGLError, EID, is_all, NID
  from .frame import Frame
  from .udf import EdgeBatch, NodeBatch
label_desc: Use image node_id 5 for calling a global function with example usage: _bucketing(val) and returns: unique_val,  bucketor, bkts