code: def _build_M(y, alphas, weight):
      """Returns the matrix defining the reprojection equations.
      Args:
          y: projected points in camera coordinates of size B x N x 2
          alphas: barycentric coordinates of size B x N x 4
          weight: Batch of non-negative weights of
              shape `(minibatch, num_point)`. `None` means equal weights.
      """
      bs, n, _ = y.size()
  
      # prepend t with the column of v's
      def prepad(t, v):
          return F.pad(t, (1, 0), value=v)
  
      if weight is not None:
          # weight the alphas in order to get a correctly weighted version of M
          alphas = alphas * weight[:, :, None]
  
      # outer left-multiply by alphas
      def lm_alphas(t):
          return torch.matmul(alphas[..., None], t).reshape(bs, n, 12)
  
      M = torch.cat(
          (
              lm_alphas(
                  prepad(prepad(-y[:, :, 0, None, None], 0.0), 1.0)
              ),  # u constraints
              lm_alphas(
                  prepad(prepad(-y[:, :, 1, None, None], 1.0), 0.0)
              ),  # v constraints
          ),
          dim=-1,
      ).reshape(bs, -1, 12)
  
      return M
  
imports: import warnings
  from typing import NamedTuple, Optional
  import torch
  import torch.nn.functional
  from pytorch3d.ops import points_alignment, utils
label_desc: Use image node_id 3 for calling a global function with example usage: _build_M(y, alphas, weight) and returns: M, F, torch