code: def test_unify_schemas():
      # Unifying a schema with the same schema as itself
      tensor_arr_1 = pa.schema(
          [("tensor_arr", ArrowTensorType((3, 5), pa.int32()))]
      )
      assert unify_schemas([tensor_arr_1, tensor_arr_1]) == tensor_arr_1
  
      # Single columns with different shapes
      tensor_arr_2 = pa.schema(
          [("tensor_arr", ArrowTensorType((2, 1), pa.int32()))]
      )
      contains_diff_shaped = [tensor_arr_1, tensor_arr_2]
      assert unify_schemas(contains_diff_shaped) == pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 2),
              ),
          ]
      )
  
      # Single columns with same shapes
      tensor_arr_3 = pa.schema(
          [("tensor_arr", ArrowTensorType((3, 5), pa.int32()))]
      )
      contains_diff_types = [tensor_arr_1, tensor_arr_3]
      assert unify_schemas(contains_diff_types) == pa.schema(
          [
              ("tensor_arr", ArrowTensorType((3, 5), pa.int32())),
          ]
      )
  
      # Single columns with a variable shaped tensor, same ndim
      var_tensor_arr = pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 2),
              ),
          ]
      )
      contains_var_shaped = [tensor_arr_1, var_tensor_arr]
      assert unify_schemas(contains_var_shaped) == pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 2),
              ),
          ]
      )
  
      # Single columns with a variable shaped tensor, different ndim
      var_tensor_arr_1d = pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 1),
              ),
          ]
      )
      var_tensor_arr_3d = pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 3),
              ),
          ]
      )
      contains_1d2d = [tensor_arr_1, var_tensor_arr_1d]
      assert unify_schemas(contains_1d2d) == pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 2),
              ),
          ]
      )
      contains_2d3d = [tensor_arr_1, var_tensor_arr_3d]
      assert unify_schemas(contains_2d3d) == pa.schema(
          [
              (
                  "tensor_arr",
                  ArrowVariableShapedTensorType(pa.int32(), 3),
              ),
          ]
      )
  
      # Multi-column schemas
      multicol_schema_1 = pa.schema(
          [
              ("col_int", pa.int32()),
              ("col_fixed_tensor", ArrowTensorType((4, 2), pa.int32())),
              (
                  "col_var_tensor",
                  ArrowVariableShapedTensorType(pa.int16(), 5),
              ),
          ]
      )
      multicol_schema_2 = pa.schema(
          [
              ("col_int", pa.int32()),
              ("col_fixed_tensor", ArrowTensorType((4, 2), pa.int32())),
              (
                  "col_var_tensor",
                  ArrowTensorType((9, 4, 1, 0, 5), pa.int16()),
              ),
          ]
      )
      assert unify_schemas(
          [multicol_schema_1, multicol_schema_2]
      ) == pa.schema(
          [
              ("col_int", pa.int32()),
              ("col_fixed_tensor", ArrowTensorType((4, 2), pa.int32())),
              (
                  "col_var_tensor",
                  ArrowVariableShapedTensorType(pa.int16(), 5),
              ),
          ]
      )
  
      multicol_schema_3 = pa.schema(
          [
              ("col_int", pa.int32()),
              (
                  "col_fixed_tensor",
                  ArrowVariableShapedTensorType(pa.int32(), 3),
              ),
              (
                  "col_var_tensor",
                  ArrowVariableShapedTensorType(pa.int16(), 5),
              ),
          ]
      )
      assert unify_schemas(
          [multicol_schema_1, multicol_schema_3]
      ) == pa.schema(
          [
              ("col_int", pa.int32()),
              (
                  "col_fixed_tensor",
                  ArrowVariableShapedTensorType(pa.int32(), 3),
              ),
              (
                  "col_var_tensor",
                  ArrowVariableShapedTensorType(pa.int16(), 5),
              ),
          ]
      )
  
      # Unifying >2 schemas together
      assert unify_schemas(
          [multicol_schema_1, multicol_schema_2, multicol_schema_3]
      ) == pa.schema(
          [
              ("col_int", pa.int32()),
              (
                  "col_fixed_tensor",
                  ArrowVariableShapedTensorType(pa.int32(), 3),
              ),
              (
                  "col_var_tensor",
                  ArrowVariableShapedTensorType(pa.int16(), 5),
              ),
          ]
      )
  
imports: import os
  import numpy
  import pandas
  import pyarrow
  import pytest
  import ray
  from ray.data._internal.arrow_ops.transform_pyarrow import concat, unify_schemas
  from ray.data.block import BlockAccessor
  from ray.data.extensions import ArrowTensorArray, ArrowTensorType, ArrowVariableShapedTensorType
label_desc: Use image node_id 9 for calling a global function with example usage: test_unify_schemas() without return types