code: def _check_instances(
      trainer: Union[
          Type[HomoTrainerClient], Type[HomoTrainerServer]
      ] = None,
      fed_args: FedArguments = None,
      model: nn.Module = None,
      optimizer: optim.Optimizer = None,
      loss: Callable = None,
      scheduler: _LRScheduler = None,
      train_args: TrainingArguments = None,
      data_collator: Callable = None,
  ) -> None:
      if trainer is not None and not (
          issubclass(type(trainer), HomoTrainerClient)
          or issubclass(type(trainer), HomoTrainerServer)
      ):
          raise TypeError(
              f"SetupReturn Error: trainer must be a subclass of either FedTrainerClient or FedTrainerServer but got {type(trainer)}"
          )
  
      if fed_args is not None and not isinstance(
          fed_args, FedArguments
      ):
          raise TypeError(
              f"SetupReturn Error: fed_args must be an instance of FedArguments but got {type(fed_args)}"
          )
  
      if model is not None and not issubclass(type(model), nn.Module):
          raise TypeError(
              f"SetupReturn Error: model must be a subclass of torch.nn.Module but got {type(model)}"
          )
  
      if optimizer is not None and not issubclass(
          type(optimizer), optim.Optimizer
      ):
          raise TypeError(
              f"SetupReturn Error: optimizer must be a subclass of torch.optim.Optimizer but got {type(optimizer)}"
          )
  
      if loss is not None and not callable(loss):
          raise TypeError(
              f"SetupReturn Error: loss must be callable but got {type(loss)}"
          )
  
      if scheduler is not None and not issubclass(
          type(scheduler), _LRScheduler
      ):
          raise TypeError(
              f"SetupReturn Error: scheduler must be a subclass of torch.optim.lr_scheduler._LRScheduler but got {type(scheduler)}"
          )
  
      if train_args is not None and not isinstance(
          train_args, TrainingArguments
      ):
          raise TypeError(
              f"SetupReturn Error: train_args must be an instance of TrainingArguments but got {type(train_args)}"
          )
  
      if data_collator is not None and not callable(data_collator):
          raise TypeError(
              f"SetupReturn Error: data_collator must be callable but got {type(data_collator)}"
          )
  
imports: import torch
  import os
  from fate.components.components.nn.nn_runner import NNRunner, load_model_dict_from_path, dir_warning, loader_load_from_conf, run_dataset_func
  from fate.ml.nn.homo.fedavg import FedAVG, FedAVGArguments, FedAVGClient, FedAVGServer
  from typing import Dict
  from fate.components.components.nn.loader import Loader
  import torch.nn
  import torch.optim
  from torch.optim.lr_scheduler import _LRScheduler
  from fate.ml.nn.trainer.trainer_base import FedArguments, TrainingArguments, HomoTrainerClient, HomoTrainerServer
  from typing import Union, Type, Callable, Optional
  from transformers.trainer_utils import get_last_checkpoint
  from typing import Literal
  import logging
  from fate.components.components.utils import consts
  from fate.ml.nn.dataset.table import TableDataset, Dataset
  from fate.arch.dataframe import DataFrame
label_desc: Use image node_id 1 for calling a global function with example usage: _check_instances(trainer, fed_args, model, optimizer, loss, scheduler, train_args, data_collator) without return types