code: def get_degree_based_edge_weights(
      edges: type_alias.TensorLike,
      dtype: type_alias.TensorLike = np.float32,
  ) -> type_alias.TensorLike:
      r"""Computes vertex degree based weights for edges of a mesh.
  
      The degree (valence) of a vertex is number of edges incident on the vertex.
      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
      $$
  
      Args:
        edges: A numpy.ndarray of shape [E, 2], where E is the number of directed
          edges in the mesh.
        dtype: A numpy float data type. The output weights are of data type dtype.
  
      Returns:
        weights: A dtype numpy.ndarray of shape [E,] denoting edge weights.
  
      Raises:
        ValueError: If `edges` is not a numpy.ndarray or if its shape is not
          supported, or dtype is not a float type.
  
      """
      if not isinstance(dtype(1), np.floating):
          raise ValueError("'dtype' must be a numpy float type.")
      if not isinstance(edges, np.ndarray):
          raise ValueError("'edges' must be a numpy.ndarray.")
      edges_shape = edges.shape
      edges_rank = len(edges_shape)
      if edges_rank != 2:
          raise ValueError(
              "'edges' must have a rank equal to 2, but it has rank {} and shape {}.".format(
                  edges_rank, edges_shape
              )
          )
      if edges_shape[1] != 2:
          raise ValueError(
              "'edges' must have exactly 2 dimensions in the last axis, but it has {}"
              " dimensions and is of shape {}.".format(
                  edges_shape[1], edges_shape
              )
          )
      degree = np.bincount(edges[:, 0])
      rep_degree = degree[edges[:, 0]]
      weights = 1.0 / rep_degree.astype(dtype)
      return weights
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 2 for calling a global function with example usage: get_degree_based_edge_weights(edges, dtype) and returns: weights