code: def block_diag(*tensors):
      shapes_list = [ivy.shape(t) for t in tensors]
      # TODO: Add ivy function to return promoted dtype for multiple tensors at once
      promoted_dtype = ivy.as_ivy_dtype(tensors[0].dtype)
      for idx in range(1, len(tensors)):
          promoted_dtype = torch_frontend.promote_types_torch(
              tensors[idx - 1].dtype, tensors[idx].dtype
          )
  
      inp_tensors = [
          ivy.asarray(t, dtype=promoted_dtype) for t in tensors
      ]
      tensors_2d = []
      result_dim_0, result_dim_1 = 0, 0
      for idx, t_shape in enumerate(shapes_list):
          dim_0, dim_1 = 1, 1
          if len(t_shape) > 2:
              raise ivy.exceptions.IvyError(
                  "Input tensors must have 2 or fewer dimensions."
                  f"Input {idx} has {len(t_shape)} dimensions"
              )
          elif len(t_shape) == 2:
              dim_0, dim_1 = t_shape
              tensors_2d.append(inp_tensors[idx])
          elif len(t_shape) == 1:
              dim_1 = t_shape[0]
              tensors_2d.append(
                  ivy.reshape(inp_tensors[idx], shape=(dim_0, dim_1))
              )
          else:
              tensors_2d.append(
                  ivy.reshape(inp_tensors[idx], shape=(dim_0, dim_1))
              )
  
          result_dim_0 += dim_0
          result_dim_1 += dim_1
          shapes_list[idx] = (dim_0, dim_1)
  
      ret = ivy.zeros(
          (result_dim_0, result_dim_1), dtype=promoted_dtype
      )
      ret_dim_0 = 0
      ret_dim_1 = 0
      for idx, t_shape in enumerate(shapes_list):
          dim_0, dim_1 = t_shape
          ret[
              ret_dim_0 : ret_dim_0 + dim_0,
              ret_dim_1 : ret_dim_1 + dim_1,
          ] = ivy.copy_array(tensors_2d[idx])
          ret_dim_0 += dim_0
          ret_dim_1 += dim_1
  
      return ret
  
imports: import ivy
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back
  from ivy.functional.frontends.torch import promote_types_of_torch_inputs
  import ivy.functional.frontends.torch
label_desc: Use image node_id 4 for calling a global function with example usage: block_diag() and returns: ret