code: def block_matrix_concat(blocks: Sequence[Sequence[Tensor]]) -> Tensor:
      rows = []
      shape = torch.broadcast_shapes(
          *(x.shape[:-2] for x in chain.from_iterable(blocks))
      )
      for tensors in blocks:
          parts = [x.expand(*shape, *x.shape[-2:]) for x in tensors]
          if len(parts) > 1:
              rows.append(torch.cat(parts, dim=-1))
          else:
              rows.extend(parts)
      return torch.concat(rows, dim=-2)
  
file_path: botorch/botorch/utils/probability/linalg.py
imports: from __future__ import annotations
  from dataclasses import dataclass, InitVar
  from itertools import chain
  from typing import Any, Optional, Sequence
  import torch
  from botorch.utils.probability.utils import swap_along_dim_
  from linear_operator.utils.errors import NotPSDError
  from torch import LongTensor, Tensor
  from torch.nn.functional import pad
label_desc: Use image node_id 1 for calling a global function with example usage: block_matrix_concat(blocks) and returns: torch