code: def adjacency_from_edges(
      edges: type_alias.TensorLike,
      weights: type_alias.TensorLike,
      num_edges: type_alias.TensorLike,
      num_vertices: type_alias.TensorLike,
  ) -> tf.SparseTensor:
      """Returns a batched sparse 1-ring adj tensor from edge list tensor.
  
      Args:
        edges: [B, E, 2] `int32` tensor of edges, possibly 0 padded.
        weights: [B, E] `float32` tensor of edge weights, possibly 0 padded.
        num_edges: [B] `int32` tensor of number of valid edges per batch sample.
        num_vertices: [B] `int32` tensor of number of valid vertices per batch
          sample.
  
      Returns:
        adj: A batched SparseTensor of weighted adjacency graph, of
          dense_shape [B, V, V] where V is max(num_vertices)
      """
      edges = tf.convert_to_tensor(value=edges)
      weights = tf.convert_to_tensor(value=weights)
      num_edges = tf.convert_to_tensor(value=num_edges)
      num_vertices = tf.convert_to_tensor(value=num_vertices)
  
      if not edges.dtype.is_integer:
          raise TypeError("'edges' must have an integer type.")
      if not num_edges.dtype.is_integer:
          raise TypeError("'num_edges' must have an integer type.")
      if not num_vertices.dtype.is_integer:
          raise TypeError("'num_vertices' must have an integer type.")
      if not weights.dtype.is_floating:
          raise TypeError("'weights' must have a floating type.")
  
      shape.check_static(tensor=edges, tensor_name="edges", has_rank=3)
      shape.check_static(
          tensor=weights, tensor_name="weights", has_rank=2
      )
      shape.check_static(
          tensor=num_edges, tensor_name="num_edges", has_rank=1
      )
      shape.check_static(
          tensor=num_vertices, tensor_name="num_vertices", has_rank=1
      )
      shape.compare_dimensions(
          tensors=(edges, weights, num_edges, num_vertices),
          tensor_names=(
              "edges",
              "weights",
              "num_edges",
              "num_vertices",
          ),
          axes=(-3, -2, -1, -1),
      )
      shape.compare_dimensions(
          tensors=(edges, weights),
          tensor_names=("edges", "weights"),
          axes=(-2, -1),
      )
  
      batch_size = tf.shape(input=edges)[0]
      max_num_vertices = tf.reduce_max(input_tensor=num_vertices)
      max_num_edges = tf.shape(input=edges)[1]
      batch_col = tf.reshape(
          tf.range(batch_size, dtype=edges.dtype), [-1, 1, 1]
      )
      batch_col = tf.tile(batch_col, [1, max_num_edges, 1])
      batch_edges = tf.concat([batch_col, edges], axis=-1)
  
      indices, _ = conv_utils.flatten_batch_to_2d(
          batch_edges, sizes=num_edges
      )
      values, _ = conv_utils.flatten_batch_to_2d(
          tf.expand_dims(weights, -1), sizes=num_edges
      )
      values = tf.squeeze(values)
      adjacency = tf.SparseTensor(
          indices=tf.cast(indices, tf.int64),
          values=values,
          dense_shape=[batch_size, max_num_vertices, max_num_vertices],
      )
      adjacency = tf.sparse.reorder(adjacency)
      return adjacency
  
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 1 for calling a global function with example usage: adjacency_from_edges(edges, weights, num_edges, num_vertices) and returns: adjacency