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:
              invalidInputError(
                  False,
                  "value of x and y should be a ndarray, "
                  "a tuple of ndarrays or a list of ndarrays",
              )
  
      result = {}
      invalidInputError(
          isinstance(data, dict), "each shard should be an dict"
      )
      invalidInputError("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: from bigdl.dllib.utils.file_utils import get_file_list, callZooFunc
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from bigdl.dllib.utils.common import *
  from bigdl.dllib.utils.log4Error import *
  import pyspark.sql.functions
  from typing import TYPE_CHECKING, Dict, List, Optional, Type, Union
  from numpy import float32, int32
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