docstr: Serialize a given item and append its size and bytes to the sizes and data array.
docstr_tok: ["Serialize","a","given","item","and","append","its","size","and","bytes","to","the","sizes","and","data","array","."]
code: def _serialize(
      self, item: Any, sizes: List[int], data: List[bytes]
  ) -> str:
      """Serialize a given item and append its size and bytes to the sizes and data array."""
      for serializer_name, serializer in self._serializers.items():
          if serializer.can_serialize(item):
              serialized_item, name = serializer.serialize(item)
              data.append(serialized_item)
              sizes.append(len(serialized_item))
              return name or serializer_name
      raise ValueError(
          f"The provided item isn't serializable. Found {item}"
      )
  
imports: import json
  import os
  import warnings
  from dataclasses import dataclass
  from time import sleep
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from lightning.data.streaming.compression import _COMPRESSORS, Compressor
  from lightning.data.streaming.constants import _INDEX_FILENAME, _TORCH_GREATER_EQUAL_2_1_0
  from lightning.data.streaming.serializers import Serializer, _get_serializers
  from lightning.data.utilities.env import _DistributedEnv, _WorkerEnv
  from lightning.data.utilities.format import _convert_bytes_to_int, _human_readable_bytes
label_desc: Use image node_id 6 for calling the BinaryWriter obj's underlying member method code with example usage: obj._serialize(item, sizes, data) and returns: unknown