code: def check_if_network_is_valid(network, index):
      if not isinstance(network, BaseGraph):
          raise TypeError(
              "Invalid input, Mixture of experts expects networks/layers"
              "in the list of networks, got `{}` instance instead"
              "".format(type(network))
          )
  
      if len(network.input_layers) > 1:
          raise ValueError(
              "Each network from the mixture of experts has to process single "
              "input tensor. Network #{} (0-based indices) has more than one "
              "input layer. Input layers: {}"
              "".format(index, network.output_layers)
          )
  
      if len(network.output_layers) > 1:
          raise ValueError(
              "Each network from the mixture of experts has to output single "
              "tensor. Network #{} (0-based indices) has more than one output "
              "layer. Output layers: {}".format(
                  index, network.output_layers
              )
          )
  
      if network.input_shape.ndims != 2:
          raise ValueError(
              "Each network from the mixture of experts has to process "
              "only 2-dimensional inputs. Network #{} (0-based indices) "
              "processes only {}-dimensional inputs. Input layer's shape: {}"
              "".format(
                  index, network.input_shape.ndims, network.input_shape
              )
          )
  
imports: import tensorflow
  from neupy import layers
  from neupy.utils import tf_utils, as_tuple
  from neupy.layers.base import BaseGraph
label_desc: Use image node_id 1 for calling a global function with example usage: check_if_network_is_valid(network, index) without return types