code: def create_mar_file(
      work_dir, serialized_file, model_archiver, model_name, request
  ):
      mar_file_path = Path(work_dir).joinpath(model_name + ".mar")
  
      name_file = REPO_ROOT_DIR.joinpath(
          "examples/image_classifier/resnet_18/index_to_name.json"
      ).as_posix()
  
      config_file = None
      if request.param == "yaml_config":
          micro_batching_params = {
              "micro_batching": {
                  "micro_batch_size": 2,
                  "parallelism": {
                      "preprocess": 2,
                      "inference": 2,
                      "postprocess": 2,
                  },
              },
          }
  
          config_file = Path(work_dir).joinpath("model_config.yaml")
  
          with open(config_file, "w") as f:
              yaml.dump(micro_batching_params, f)
          config_file = REPO_ROOT_DIR.joinpath(
              "examples", "micro_batching", "config.yaml"
          )
  
      extra_files = [name_file]
  
      config = ModelArchiverConfig(
          model_name=model_name,
          version="1.0",
          serialized_file=str(serialized_file),
          model_file=REPO_ROOT_DIR.joinpath(
              "examples", "image_classifier", "resnet_18", "model.py"
          ).as_posix(),
          handler=REPO_ROOT_DIR.joinpath(
              "examples", "micro_batching", "micro_batching_handler.py"
          ).as_posix(),
          extra_files=",".join(extra_files),
          export_path=work_dir,
          requirements_file=None,
          runtime="python",
          force=False,
          archive_format="default",
          config_file=config_file,
      )
  
      with patch(
          "archiver.ArgParser.export_model_args_parser",
          return_value=config,
      ):
          # Using ZIP_STORED instead of ZIP_DEFLATED reduces test runtime from 54 secs to 10 secs
          with patch(
              "model_archiver.model_packaging_utils.zipfile.ZipFile",
              lambda x, y, _: ZipFile(x, y, ZIP_STORED),
          ):
              model_archiver.generate_model_archive()
  
              assert mar_file_path.exists()
  
              yield mar_file_path.as_posix()
  
      # Clean up files
      mar_file_path.unlink(missing_ok=True)
  
imports: import asyncio
  import json
  import random
  import shutil
  from pathlib import Path
  from unittest.mock import patch
  from zipfile import ZIP_STORED, ZipFile
  import pytest
  import requests
  import test_utils
  import yaml
  from model_archiver import ModelArchiverConfig
  from torchvision.models.resnet import ResNet18_Weights
  from ts.torch_handler.unit_tests.test_utils.model_dir import download_model
label_desc: Use image node_id 8 for calling a global function with example usage: create_mar_file(work_dir, serialized_file, model_archiver, model_name, request) without return types