code: def generate_case_from_nntxt_str(
      nntxt_str, param_format, dataset_sample_num, batch_size=None
  ):
      proto = proto_from_str(nntxt_str)
      with generate_csv_png(
          dataset_sample_num, get_input_size(proto)
      ) as dataset_csv_file:
          # To test dataset, we create a randomly generated dataset.
          for ds in proto.dataset:
              ds.batch_size = (
                  batch_size if batch_size else ds.batch_size
              )
              ds.uri = dataset_csv_file
              ds.cache_dir = os.path.join(
                  os.path.dirname(dataset_csv_file), "data.cache"
              )
          nntxt_io = io.StringIO()
          text_format.PrintMessage(proto, nntxt_io)
          nntxt_io.seek(0)
  
          version = io.StringIO()
          version.write("{}\n".format(nnp_version()))
          version.seek(0)
  
          param = io.BytesIO()
          prepare_parameters(nntxt_str)
          nn.parameter.save_parameters(param, extension=param_format)
  
          with create_temp_with_dir(NNP_FILE) as temp_nnp_file_name:
              with get_file_handle_save(
                  temp_nnp_file_name, ".nnp"
              ) as nnp:
                  nnp.writestr("nnp_version.txt", version.read())
                  nnp.writestr("network.nntxt", nntxt_io.read())
                  nnp.writestr(
                      "parameter{}".format(param_format), param.read()
                  )
              yield temp_nnp_file_name
  
imports: import os
  import io
  import pytest
  import numpy
  import nnabla
  import nnabla.functions
  from nnabla.testing import assert_allclose
  from contextlib import contextmanager
  from shutil import rmtree
  import tempfile
  import numpy
  import warnings
  from legacy_expander import NnpExpander
  from nnabla.utils import nnabla_pb2
  from legacy_load import _create_variable
  import google.protobuf.text_format
  from nnabla.utils.image_utils import imsave
  from nnabla.utils.get_file_handle import get_file_handle_save
  from nnabla.utils.nnp_format import nnp_version
label_desc: Use image node_id 13 for calling a global function with example usage: generate_case_from_nntxt_str(nntxt_str, param_format, dataset_sample_num, batch_size) without return types