code: def test_model_export_import(bento_model, tmpdir: "Path"):
      # note: these tests rely on created models having a system path
      sys_written_path = bento_model.path_of("sys_written/file")
      assert sys_written_path == os.path.join(
          bento_model.path, "sys_written", "file"
      )
  
      os.makedirs(os.path.dirname(sys_written_path))
      sys_written_content = "this is a test\n"
      with open(
          sys_written_path, mode="w", encoding="utf-8", newline=""
      ) as sys_written_file:
          sys_written_file.write(sys_written_content)
  
      with open(
          bento_model.path_of("sys_written/file"), encoding="utf-8"
      ) as f:
          assert f.read() == sys_written_content
  
      export_tar_path = (
          f"tar://{fs.path.join(str(tmpdir), 'model_b.tar')}"
      )
      bento_model.export(export_tar_path)
      tar_fs = fs.open_fs(export_tar_path)
      from_tar_model = Model.from_fs(tar_fs)
  
      assert from_tar_model == bento_model
      assert from_tar_model.info == bento_model.info
      assert (
          from_tar_model._fs.readtext("sys_written/file")  # type: ignore
          == sys_written_content
      )
      assert from_tar_model.custom_objects["add"](4) == add_num_1 + 4  # type: ignore
      with pytest.raises(fs.errors.NoSysPath):
          assert from_tar_model.path
  
      # tmpdir/modelb.bentomodel
      export_bentomodel_path = fs.path.join(
          str(tmpdir), "modelb.bentomodel"
      )
      bento_model.export(export_bentomodel_path)
  
      from_fs_model = Model.from_fs(
          fs.tarfs.TarFS(export_bentomodel_path, compression="xz")
      )
  
      # can cause model.path to fail by using `from_fs`.
      with pytest.raises(fs.errors.NoSysPath):
          assert from_fs_model.path
  
      model_store = ModelStore(tmpdir)
      from_fs_model.save(model_store)
  
      save_path = os.path.join(
          tmpdir,
          os.path.join(
              from_fs_model.tag.name, from_fs_model.tag.version
          )
          + os.path.sep,
      )
      assert str(from_fs_model) == f'Model(tag="{bento_model.tag}")'
      assert (
          repr(from_fs_model)
          == f'Model(tag="{bento_model.tag}", path="{save_path}")'
      )
  
imports: from __future__ import annotations
  import os
  from datetime import datetime
  from datetime import timezone
  from sys import version_info
  from typing import TYPE_CHECKING
  import attr
  import fs
  import fs.errors
  import numpy
  import pytest
  from bentoml import Tag
  from bentoml._internal.configuration import BENTOML_VERSION
  from bentoml._internal.models import ModelOptions
  from bentoml._internal.models.model import Model
  from bentoml._internal.models.model import ModelInfo
  from bentoml._internal.models.model import ModelStore
  from bentoml.exceptions import BentoMLException
  from bentoml.testing.pytest import TEST_MODEL_CONTEXT
label_desc: Use image node_id 6 for calling a global function with example usage: test_model_export_import(bento_model, tmpdir) without return types