code: def r_squared(
      XB: NDArray[Float], Y: NDArray[Float]
  ) -> NDArray[(Any,), Float]:
      """
      Computes the coefficient of determination (R2) metric between the matrix resulting from X*B and the matrix of labels
      Y.
  
      Args:
          XB : Matrix representing the result of the multiplication X*B, where X is a matrix of [number of samples] x
          [number of headers] and B is a matrix of [number of headers x number of alphas * number of labels]
          Y : Matrix of labels, with [number of samples x number of labels]
  
      Returns:
          Array of [number of alphas * number of labels]
      """
      tot = np.power(Y - Y.mean(), 2).sum()
      res = np.power(Y - XB, 2).sum(axis=0)
      return 1 - (res / tot)
  
imports: import itertools
  import math
  import re
  import warnings
  from typing import Any, Dict, Iterable, List, Tuple
  import numpy
  import pandas
  import pyspark.sql.functions
  import scipy.optimize
  from nptyping import Float, Int, NDArray
  from pyspark.sql import DataFrame, Row
  from pyspark.sql.window import Window
  from typeguard import typechecked
label_desc: Use image node_id 12 for calling a global function with example usage: r_squared(XB, Y) and returns: unknown