class_docstr: Compact tensor storage to keep tensor data of predefined size and type.
docstr: Construct tensor storage based on information on data shape and size.
  Internally uses numpy to interpret the type specification.
  The storage must support operations `seek(offset, whence=os.SEEK_SET)` and
  `read(size)` to be able to perform the `get` operation.
  The storage must support operation `write(bytes)` to be able to perform
  the `put` operation.
  
  Args:
      data_schema (dict: str -> SizeData): dictionary which maps tensor name
          to its size data (shape and data type), e.g.
          ```
          {
            "coarse_segm": SizeData(dtype="float32", shape=(112, 112)),
            "embedding": SizeData(dtype="float32", shape=(16, 112, 112)),
          }
          ```
      storage_impl (BinaryIO): io instance that handles file-like seek, read
          and write operations, e.g. a file handle or a memory buffer like io.BytesIO
docstr_tok: ["Construct","tensor","storage","based","on","information","on","data","shape","and","size",".","Internally","uses","numpy","to","interpret","the","type","specification",".","The","storage","must","support","operations","`","seek","(","offset",",","whence=os.SEEK_SET",")","`","and","`","read","(","size",")","`","to","be","able","to","perform","the","`","get","`","operation",".","The","storage","must","support","operation","`","write","(","bytes",")","`","to","be","able","to","perform","the","`","put","`","operation",".","Args",":","data_schema","(","dict",":","str","-",">","SizeData",")",":","dictionary","which","maps","tensor","name","to","its","size","data","(","shape","and","data","type",")",",","e.g",".","``","`","{","``","coarse_segm","''",":","SizeData","(","dtype=","''","float32","''",",","shape=","(","112",",","112",")",")",",","``","embedding","''",":","SizeData","(","dtype=","''","float32","''",",","shape=","(","16",",","112",",","112",")",")",",","}","``","`","storage_impl","(","BinaryIO",")",":","io","instance","that","handles","file-like","seek",",","read","and","write","operations",",","e.g",".","a","file","handle","or","a","memory","buffer","like","io.BytesIO"]
code: def __init__(
      self, data_schema: Dict[str, SizeData], storage_impl: BinaryIO
  ):
      """
      Construct tensor storage based on information on data shape and size.
      Internally uses numpy to interpret the type specification.
      The storage must support operations `seek(offset, whence=os.SEEK_SET)` and
      `read(size)` to be able to perform the `get` operation.
      The storage must support operation `write(bytes)` to be able to perform
      the `put` operation.
  
      Args:
          data_schema (dict: str -> SizeData): dictionary which maps tensor name
              to its size data (shape and data type), e.g.
              ```
              {
                "coarse_segm": SizeData(dtype="float32", shape=(112, 112)),
                "embedding": SizeData(dtype="float32", shape=(16, 112, 112)),
              }
              ```
          storage_impl (BinaryIO): io instance that handles file-like seek, read
              and write operations, e.g. a file handle or a memory buffer like io.BytesIO
      """
      self.data_schema = data_schema
      self.record_size_b = _calculate_record_size_b(data_schema)
      self.record_field_sizes_b = _calculate_record_field_sizes_b(
          data_schema
      )
      self.storage_impl = storage_impl
      self.next_record_id = 0
  
imports: import io
  import numpy
  import os
  from dataclasses import dataclass
  from functools import reduce
  from operator import mul
  from typing import BinaryIO, Dict, Optional, Tuple
  import torch
  from detectron2.utils.comm import gather, get_rank
  from detectron2.utils.file_io import PathManager
label_desc: Use image node_id 1 to create a new SingleProcessTensorStorage object  with example: obj = SingleProcessTensorStorage(data_schema, storage_impl)