code: def check_data_cardinality(data):
      num_samples = set(int(i.shape[0]) for i in tree.flatten(data))
      if len(num_samples) > 1:
          msg = (
              "Data cardinality is ambiguous. "
              "Make sure all arrays contain the same number of samples."
          )
          for label, single_data in zip(
              ["x", "y", "sample_weight"], data
          ):
              sizes = ", ".join(
                  str(i.shape[0]) for i in tree.flatten(single_data)
              )
              msg += f"'{label}' sizes: {sizes}\n"
          raise ValueError(msg)
  
file_path: keras/keras/trainers/data_adapters/data_adapter_utils.py
imports: import math
  import numpy
  import tree
  from keras import backend
  from keras.api_export import keras_export
label_desc: Use image node_id 4 for calling a global function with example usage: check_data_cardinality(data) without return types