code: def convert_model_to_external_data(
      model: ModelProto,
      all_tensors_to_one_file: bool = True,
      location: Optional[str] = None,
      size_threshold: int = 1024,
      convert_attribute: bool = False,
  ) -> None:
      """Call to set all tensors with raw data as external data. This call should precede 'save_model'.
      'save_model' saves all the tensors data as external data after calling this function.
  
      Arguments:
          model (ModelProto): Model to be converted.
          all_tensors_to_one_file (bool): If true, save all tensors to one external file specified by location.
              If false, save each tensor to a file named with the tensor name.
          location: specify the external file relative to the model that all tensors to save to.
              Path is relative to the model path.
              If not specified, will use the model name.
          size_threshold: Threshold for size of data. Only when tensor's data is >= the size_threshold
              it will be converted to external data. To convert every tensor with raw data to external data set size_threshold=0.
          convert_attribute (bool): If true, convert all tensors to external data
                         If false, convert only non-attribute tensors to external data
      """
      tensors = _get_initializer_tensors(model)
      if convert_attribute:
          tensors = _get_all_tensors(model)
  
      if all_tensors_to_one_file:
          file_name = str(uuid.uuid1())
          if location:
              if os.path.isabs(location):
                  raise ValueError(
                      "location must be a relative path that is relative to the model path."
                  )
              file_name = location
          for tensor in tensors:
              if (
                  tensor.HasField("raw_data")
                  and sys.getsizeof(tensor.raw_data) >= size_threshold
              ):
                  set_external_data(tensor, file_name)
      else:
          for tensor in tensors:
              if (
                  tensor.HasField("raw_data")
                  and sys.getsizeof(tensor.raw_data) >= size_threshold
              ):
                  tensor_location = tensor.name
                  if not _is_valid_filename(tensor_location):
                      tensor_location = str(uuid.uuid1())
                  set_external_data(tensor, tensor_location)
  
imports: import os
  import re
  import sys
  import uuid
  from itertools import chain
  from typing import Callable, Iterable, Optional
  from onnx.onnx_pb import AttributeProto, GraphProto, ModelProto, TensorProto
label_desc: Use image node_id 4 for calling a global function with example usage: convert_model_to_external_data(model, all_tensors_to_one_file, location, size_threshold, convert_attribute) without return types