#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1269
Task: </think>

Write a Python function that takes a list of 3D tensors and merges them along the first dimension, returning a single 4D tensor. The function should be testable using PyTorch with sample inp
Generated: 2026-02-13T02:27:33.720460
"""

import torch

def merge_tensors(tensor_list):
    """
    Merges a list of 3D tensors along the first dimension (batch dimension)
    to form a single 4D tensor.

    Args:
        tensor_list (list): List of 3D tensors (each with shape (C, H, W)).

    Returns:
        torch.Tensor: 4D tensor with shape (batch_size, C, H, W).
    """
    return torch.stack(tensor_list, dim=0)

if __name__ == '__main__':
    # Example input tensors
    tensor1 = torch.randn(3, 224, 224)
    tensor2 = torch.randn(3, 224, 224)
    tensor3 = torch.randn(3, 224, 224)
    
    tensor_list = [tensor1, tensor2, tensor3]
    
    merged_tensor = merge_tensors(tensor_list)
    
    print("Merged Tensor Shape:", merged_tensor.shape)
    print("Merged Tensor:\n", merged_tensor)