code: def linear_coefficients(
      matte: type_alias.TensorLike,
      pseudo_inverse: type_alias.TensorLike,
      name: str = "matting_linear_coefficients",
  ) -> Tuple[tf.Tensor, tf.Tensor]:
      """Computes the matting linear coefficients.
  
      Computes the matting linear coefficients (a, b) based on the `pseudo_inverse`
      generated by the `build_matrices` function which implements the approach
      proposed by Levin et al. in "A Closed Form Solution to Natural Image Matting".
  
      Args:
        matte: A tensor of shape `[B, H, W, 1]`.
        pseudo_inverse: A tensor of shape `[B, H - pad, W - pad, C + 1, size^2]`
          containing the pseudo-inverse matrices computed by the `build_matrices`
          function, where `pad` is equal to `size - 1` and `size` is the patch size
          used to compute this tensor.
        name: A name for this op. Defaults to "matting_linear_coefficients".
  
      Returns:
        A tuple contraining two Tensors for the linear coefficients (a, b) of shape
        `[B, H, W, C]` and `[B, H, W, 1]`.
  
      Raises:
        ValueError: If the last dimension of `matte` is not 1. If `matte` is not
        of rank 4. If `pseudo_inverse` is not of rank 5. If `B` is different
        between `matte` and `pseudo_inverse`.
      """
      with tf.name_scope(name):
          matte = tf.convert_to_tensor(value=matte)
          pseudo_inverse = tf.convert_to_tensor(value=pseudo_inverse)
  
          pixels = tf.compat.dimension_value(pseudo_inverse.shape[-1])
          shape.check_static(matte, has_rank=4, has_dim_equals=(-1, 1))
          shape.check_static(pseudo_inverse, has_rank=5)
          shape.compare_batch_dimensions(
              tensors=(matte, pseudo_inverse),
              last_axes=0,
              broadcast_compatible=False,
          )
  
          size = np.sqrt(pixels)
          # Computes the linear coefficients.
          patches = tf.expand_dims(_image_patches(matte, size), axis=-1)
          coeffs = tf.squeeze(
              tf.matmul(pseudo_inverse, patches), axis=-1
          )
          # Averages the linear coefficients over patches.
          height = tf.shape(input=coeffs)[1]
          width = tf.shape(input=coeffs)[2]
          ones = tf.ones(
              shape=_shape((1,), height, width, 1), dtype=matte.dtype
          )
          height = tf.shape(input=matte)[1] + size - 1
          width = tf.shape(input=matte)[2] + size - 1
          coeffs = tf.image.resize_with_crop_or_pad(
              coeffs, height, width
          )
          ones = tf.image.resize_with_crop_or_pad(ones, height, width)
          coeffs = _image_average(coeffs, size) / _image_average(
              ones, size
          )
          return tf.split(coeffs, (-1, 1), axis=-1)
  
file_path: graphics/tensorflow_graphics/image/matting.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import List, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow_graphics.math import vector
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import export_api
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 6 for calling a global function with example usage: linear_coefficients(matte, pseudo_inverse, name) and returns: tf