code: def _laplacian_matrix(
      image, size=3, eps=1e-5, name="matting_laplacian_matrix"
  ):
      """Generates the closed form matting Laplacian matrices.
  
      Generates the closed form matting Laplacian as proposed by Levin et
      al. in "A Closed Form Solution to Natural Image Matting".
  
      Args:
        image: A tensor of shape `[B, H, W, C]`.
        size: An `int` representing the size of the patches used to enforce
          smoothness.
        eps: A small number of type `float` to regularize the problem.
        name: A name for this op. Defaults to "matting_laplacian_matrix".
  
      Returns:
        A tensor of shape `[B, H, W, size^2, size^2]` containing the
        matting Laplacian matrices.
  
      Raises:
        ValueError: If `image` is not of rank 4.
      """
      with tf.name_scope(name):
          image = tf.convert_to_tensor(value=image)
  
          shape.check_static(image, has_rank=4)
          if size % 2 == 0:
              raise ValueError(
                  "The patch size is expected to be an odd value."
              )
  
          pixels = size**2
          channels = tf.shape(input=image)[-1]
          dtype = image.dtype
          patches = tf.image.extract_patches(
              image,
              sizes=(1, size, size, 1),
              strides=(1, 1, 1, 1),
              rates=(1, 1, 1, 1),
              padding="VALID",
          )
          batches = tf.shape(input=patches)[:-1]
          new_shape = tf.concat((batches, (pixels, channels)), axis=-1)
          patches = tf.reshape(patches, shape=new_shape)
          mean = tf.reduce_mean(
              input_tensor=patches, axis=-2, keepdims=True
          )
          demean = patches - mean
          covariance = (
              tf.matmul(demean, demean, transpose_a=True) / pixels
          )
          regularizer = (eps / pixels) * tf.eye(channels, dtype=dtype)
          covariance_inv = tf.linalg.inv(covariance + regularizer)
          covariance_inv = asserts.assert_no_infs_or_nans(
              covariance_inv
          )
          mat = tf.matmul(
              tf.matmul(demean, covariance_inv),
              demean,
              transpose_b=True,
          )
          return tf.eye(pixels, dtype=dtype) - (1.0 + mat) / pixels
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_graphics.image import matting
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 1 for calling a global function with example usage: _laplacian_matrix(image, size, eps, name) and returns: unknown