class_docstr: context manager version of trace(); can redirect the trace to a file
class_docstr_tok: ["context","manager","version","of","trace","(",")",";","can","redirect","the","trace","to","a","file"]
code: def __init__(self, file, mode):
      self.file = file
      self.mode = mode
      self.redirect = file is not None
      self.file_is_stream = hasattr(file, "write")
  
imports: import codecs
  import contextlib
  import locale
  import logging
  import math
  import os
  from functools import partial
  from typing import TextIO, Union
  import dill
label_desc: Use image node_id 1 to create a new TraceManager object from inherited base classes: contextlib with example: obj = TraceManager(file, mode)