code: def test_nnabla_models_imagenet_etc(
      model_class,
      up_to_list,
      image_size_factor,
      batch_size,
      training,
      seed,
  ):
      model_module = importlib.import_module("nnabla.models.imagenet")
      nn.clear_parameters()
      rng = np.random.RandomState(seed)
  
      # Load model
      model = getattr(model_module, model_class)()
  
      # Determine input shape and create input variable
      input_shape = list(model.input_shape)
      input_shape[1] *= image_size_factor
      input_shape[2] *= image_size_factor
      input_shape = tuple(input_shape)
      x = nn.Variable.from_numpy_array(
          rng.randint(0, 256, size=(batch_size,) + input_shape)
      )
  
      # Test cases for all intermediate outputs
      for use_up_to in up_to_list:
          check_global_pooling = True
          force_global_pooling = False
          returns_net = False
  
          def _execute():
              y = model(
                  x,
                  training=training,
                  use_up_to=use_up_to,
                  force_global_pooling=force_global_pooling,
                  check_global_pooling=check_global_pooling,
              )
              y.forward()
  
          # Need special care for SENet because it contains global average
          # pooling in various points in a network.
          if image_size_factor != 1 and (
              model_class == "SENet"
              or use_up_to in ("classifier", "pool")
          ):
              with pytest.raises(ValueError):
                  _execute()
              if use_up_to == "pool" and model_class != "SENet":
                  check_global_pooling = False
                  _execute()
              force_global_pooling = True
          _execute()
          net = model(
              x,
              training=training,
              use_up_to=use_up_to,
              force_global_pooling=force_global_pooling,
              check_global_pooling=check_global_pooling,
              returns_net=True,
          )
          assert isinstance(net, NnpNetwork)
          assert len(net.inputs.values()) == 1
          assert len(net.outputs.values()) == 1
          y = list(net.outputs.values())[0]
          if training:
              assert _check_trainable_parameters(y)
          else:
              assert not _check_trainable_parameters(y)
  
file_path: nnabla/python/test/models/test_imagenet.py
imports: from __future__ import absolute_import
  import pytest
  import importlib
  from nnabla.utils.nnp_graph import NnpNetwork
  import nnabla
  import numpy
  from nnabla.models.utils import get_model_url_base_from_env
label_desc: Use image node_id 2 for calling a global function with example usage: test_nnabla_models_imagenet_etc(model_class, up_to_list, image_size_factor, batch_size, training, seed) without return types