code: def _block_diagonal(factor_matrices):
      """Put a list of square matrices in block diagonal form."""
      shapes_dict = {}
      for i, matrix_i in enumerate(factor_matrices):
          for j, matrix_j in enumerate(factor_matrices):
              shapes_dict[(i, j)] = (
                  matrix_i.shape[:-1] + matrix_j.shape[-1:]
              )
      rows = []
      # concacatenate along axis = -2
      for i, matrix_i in enumerate(factor_matrices):
          # concatenate along axis = -1
          blocks_to_concatenate = []
          for j, _ in enumerate(factor_matrices):
              if i == j:
                  blocks_to_concatenate.append(matrix_i)
              else:
                  blocks_to_concatenate.append(
                      gs.zeros(shapes_dict[(i, j)])
                  )
          row = gs.concatenate(blocks_to_concatenate, axis=-1)
          rows.append(row)
      metric_matrix = gs.concatenate(rows, axis=-2)
      return metric_matrix
  
imports: import math
  import geomstats.backend
  import geomstats.errors
  from geomstats.geometry.complex_manifold import ComplexManifold
  from geomstats.geometry.complex_riemannian_metric import ComplexRiemannianMetric
  from geomstats.geometry.manifold import Manifold
  from geomstats.geometry.riemannian_metric import RiemannianMetric
  from geomstats.vectorization import get_batch_shape
label_desc: Use image node_id 4 for calling a global function with example usage: _block_diagonal(factor_matrices) and returns: metric_matrix