class_docstr: Implements an API to store large tensors outside the main ModelProto,
  it avoids copying large initializers when defining the model and these initializers
  are never serialized through protobuf.
  No tensor is stored on disk until the user explicitly saves the model.
class_docstr_tok: ["Implements","an","API","to","store","large","tensors","outside","the","main","ModelProto",",","it","avoids","copying","large","initializers","when","defining","the","model","and","these","initializers","are","never","serialized","through","protobuf",".","No","tensor","is","stored","on","disk","until","the","user","explicitly","saves","the","model","."]
docstr: Loads large initializers.
  
  Arguments:
      file_path: model file, the weight are expected to be in the same folder as this file
docstr_tok: ["Loads","large","initializers",".","Arguments",":","file_path",":","model","file",",","the","weight","are","expected","to","be","in","the","same","folder","as","this","file"]
code: def _load_large_initializers(self, file_path):
      """Loads large initializers.
  
      Arguments:
          file_path: model file, the weight are expected to be in the same folder as this file
      """
      if self.model_proto_ is None:
          raise RuntimeError(
              "A model must be loaded before loading the weights."
          )
      self.large_initializers = {}
      base_dir = os.path.dirname(file_path)
      for i, tensor in enumerate(
          ext_data._get_all_tensors(self.model_proto_)
      ):
          if not ext_data.uses_external_data(tensor):
              continue
  
          info = ext_data.ExternalDataInfo(tensor)
          file_location = ext_data._sanitize_path(info.location)
          external_data_file_path = os.path.join(
              base_dir, file_location
          )
          key = f"#t{i}"
          _set_external_data(tensor, location=key)
  
          with open(external_data_file_path, "rb") as data_file:
              if info.offset:
                  data_file.seek(info.offset)
  
              raw_data = (
                  data_file.read(info.length)
                  if info.length
                  else data_file.read()
              )
  
              dtype = onnx.helper.tensor_dtype_to_np_dtype(
                  tensor.data_type
              )
              shape = tuple(tensor.dims)
  
              if sys.byteorder == "big":
                  np_tensor = (
                      np.frombuffer(raw_data, dtype=dtype)
                      .byteswap()
                      .reshape(shape)
                  )
              else:
                  np_tensor = np.frombuffer(
                      raw_data, dtype=dtype
                  ).reshape(shape)
  
              self.large_initializers[key] = np_tensor
  
imports: from __future__ import annotations
  import os
  import sys
  from typing import Any, Iterable
  import numpy
  import onnx
  import onnx.external_data_helper
  import onnx.helper
label_desc: Use image node_id 13 for calling the ModelContainer obj's underlying member method code with example usage: obj._load_large_initializers(file_path) without return types