code: def expand_and_copy_tensor(
      X: Tensor, batch_shape: torch.Size
  ) -> Tensor:
      r"""Expand and copy X according to batch_shape.
  
      Args:
          X: A `input_batch_shape x n x d`-dim tensor of inputs.
          batch_shape: The new batch shape.
  
      Returns:
          A `new_batch_shape x n x d`-dim tensor of inputs, where `new_batch_shape`
          is `input_batch_shape` against `batch_shape`.
      """
      try:
          batch_shape = torch.broadcast_shapes(
              X.shape[:-2], batch_shape
          )
      except RuntimeError:
          raise RuntimeError(
              f"Provided batch shape ({batch_shape}) and input batch shape "
              f"({X.shape[:-2]}) are not broadcastable."
          )
      expand_shape = batch_shape + X.shape[-2:]
      return X.expand(expand_shape).clone()
  
file_path: botorch/botorch/models/transforms/utils.py
imports: from __future__ import annotations
  from functools import wraps
  from typing import Tuple
  import torch
  from torch import Tensor
label_desc: Use image node_id 5 for calling a global function with example usage: expand_and_copy_tensor(X, batch_shape) and returns: X