code: def get_weighted_edges(
      faces: np.ndarray, self_edges: bool = True
  ) -> Tuple[np.ndarray, np.ndarray]:
      r"""Gets unique edges and degree weights from a triangular mesh.
  
      The shorthands used below are:
          `T`: The number of triangles in the mesh.
          `E`: The number of unique directed edges in the mesh.
  
      Args:
        faces: A [T, 3] `int32` numpy.ndarray of triangle vertex indices.
        self_edges: A `bool` flag. If true, then for every vertex 'i' an edge
          [i, i] is added to edge list.
      Returns:
        edges: A  [E, 2] `int32` numpy.ndarray of directed edges.
        weights: A [E] `float32` numpy.ndarray denoting edge weights.
  
        The degree of a vertex is the number of edges incident on the vertex,
        including any self-edges. The weight for an edge $w_{ij}$ connecting vertex
        $v_i$ and vertex $v_j$ is defined as,
        $$
        w_{ij} = 1.0 / degree(v_i)
        \sum_{j} w_{ij} = 1
        $$
      """
      edges = mesh_utils.extract_unique_edges_from_triangular_mesh(
          faces, directed_edges=True
      ).astype(np.int32)
      if self_edges:
          vertices = np.expand_dims(np.unique(edges[:, 0]), axis=1)
          self_edges = np.concatenate((vertices, vertices), axis=1)
          edges = np.unique(
              np.concatenate((edges, self_edges), axis=0), axis=0
          )
      weights = mesh_utils.get_degree_based_edge_weights(
          edges, dtype=np.float32
      )
      return edges, weights
  
file_path: graphics/tensorflow_graphics/notebooks/mesh_segmentation_dataio.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Any, Callable, Dict, List, Tuple
  import numpy
  import tensorflow
  from tensorflow_graphics.geometry.convolution import utils
  from tensorflow_graphics.geometry.representation.mesh import utils
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 2 for calling a global function with example usage: get_weighted_edges(faces, _edges) and returns: edges,  weights