class_docstr: Mix in to safely decode data that is delivered in parts
  
  This class can be used to decode data that is partially delivered.
  It detects partial encodings and stores the non-decoded data to
  combine it with additional data, that is delivered later,  and
  decodes the combined data.
  
  Any un-decoded data is stored in the 'remaining_data'-attribute.
class_docstr_tok: ["Mix","in","to","safely","decode","data","that","is","delivered","in","parts","This","class","can","be","used","to","decode","data","that","is","partially","delivered",".","It","detects","partial","encodings","and","stores","the","non-decoded","data","to","combine","it","with","additional","data",",","that","is","delivered","later",",","and","decodes","the","combined","data",".","Any","un-decoded","data","is","stored","in","the","'remaining_data'-attribute","."]
code: def decode(self, fd: int, data: bytes, encoding: str) -> str:
      assembled_data = self.remaining_data[fd] + data
      try:
          unicode_str = assembled_data.decode(encoding)
          self.remaining_data[fd] = b""
      except UnicodeDecodeError as e:
          unicode_str = assembled_data[: e.start].decode(encoding)
          self.remaining_data[fd] = assembled_data[e.start :]
      return unicode_str
  
file_path: datalad/datalad/runner/utils.py
imports: from __future__ import annotations
  import logging
  from collections import defaultdict
  from typing import Optional
label_desc: Use image node_id 2 for calling the AssemblingDecoderMixIn obj's underlying member method code with example usage: obj.decode(fd, data, encoding) and returns: unicode_str