code: def check_type_and_convert(data, allow_tuple=True, allow_list=True):
      """
      :param allow_tuple: boolean, if the model accepts a tuple as input. Default: True
      :param allow_list: boolean, if the model accepts a list as input. Default: True
      :return:
      """
  
      def check_and_convert(convert_data):
          if isinstance(convert_data, np.ndarray):
              return [convert_data]
          elif isinstance(convert_data, tuple) and all(
              [isinstance(d, np.ndarray) for d in convert_data]
          ):
              return _convert_list_tuple(
                  convert_data,
                  allow_tuple=allow_tuple,
                  allow_list=allow_list,
              )
          elif isinstance(convert_data, list) and all(
              [isinstance(d, np.ndarray) for d in convert_data]
          ):
              return _convert_list_tuple(
                  convert_data,
                  allow_tuple=allow_tuple,
                  allow_list=allow_list,
              )
          else:
              raise ValueError(
                  "value of x and y should be a ndarray, "
                  "a tuple of ndarrays or a list of ndarrays"
              )
  
      result = {}
      assert isinstance(data, dict), "each shard should be an dict"
      assert "x" in data, "key x should in each shard"
      x = data["x"]
      result["x"] = check_and_convert(x)
      if "y" in data:
          y = data["y"]
          result["y"] = check_and_convert(y)
      return result
  
imports: import os
  import numpy
  from zoo.common import get_file_list
  from zoo.util.utils import convert_row_to_numpy
label_desc: Use image node_id 3 for calling a global function with example usage: check_type_and_convert(data, allow_tuple, allow_list) and returns: result, list, _convert_list_tuple, _convert_list_tuple