code: def _transform_output_shape(
      output: Tensor, shape: Tuple[int, ...]
  ) -> Tensor:
      r"""Collapse the broadcasted batch dimensions an input tensor to be the specified shape.
      Args:
          input: Tensor
          shape: List/tuple of int
  
      Returns:
          Tensor
      """
      out_tensor = output.clone()
  
      for dim in range(len(out_tensor.shape) - len(shape)):
          if out_tensor.shape[0] != 1:
              raise AssertionError(
                  f"Dimension {dim} of input is expected to be 1, got {out_tensor.shape[0]}"
              )
          out_tensor = out_tensor.squeeze(0)
  
      return out_tensor
  
imports: from functools import wraps
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  from torch.distributions import Beta, Uniform
  from kornia.core import Tensor, as_tensor
  from kornia.geometry.boxes import Boxes
  from kornia.geometry.keypoints import Keypoints
  from kornia.utils import _extract_device_dtype
label_desc: Use image node_id 8 for calling a global function with example usage: _transform_output_shape(output, shape) and returns: out_tensor