code: def _check_input_type_when_list(second_level_input):
      """Determine the type of input provided when it is a list."""
      if len(second_level_input) < 2:
          raise TypeError(
              "A second level model requires a list with at"
              " least two first level models or niimgs"
          )
      _check_all_elements_of_same_type(second_level_input)
      if all(
          isinstance(x, (str, Nifti1Image)) for x in second_level_input
      ):
          return "nii_object"
      if all(
          isinstance(x, FirstLevelModel) for x in second_level_input
      ):
          return "flm_object"
      raise TypeError(
          "second_level_input must be "
          "either a pandas DataFrame, "
          "a Niimg-like object, "
          "a list of Niimg-like object or "
          "a list of FirstLevelModel objects. "
          f"Got {_return_type(second_level_input)} instead"
      )
  
imports: import sys
  import time
  from warnings import warn
  import numpy
  import pandas
  from joblib import Memory
  from nibabel import Nifti1Image
  from sklearn.base import clone
  from nilearn._utils import fill_doc, stringify_path
  from nilearn._utils.niimg_conversions import check_niimg
  from nilearn.glm._base import BaseGLM
  from nilearn.glm.contrasts import compute_contrast, expression_to_contrast_vector
  from nilearn.glm.first_level import FirstLevelModel, run_glm
  from nilearn.glm.first_level.design_matrix import make_second_level_design_matrix
  from nilearn.glm.regression import RegressionResults, SimpleRegressionResults
  from nilearn.image import mean_img
  from nilearn.maskers import NiftiMasker
  from nilearn.mass_univariate import permuted_ols
label_desc: Use image node_id 4 for calling a global function with example usage: _check_input_type_when_list(second_level_input) and returns: str, str