class_docstr: Writer to write dictionaries of numpy arrays in binary format.
  
  Writes dictionaries with string keys and numpy array values as records into
  a [tfrecords](https://www.tensorflow.org/tutorials/load_data/tfrecord) file.
  The usage of tfrecords should be treated as an implementation detail. To
  read the file, use the `ArrayDictReader` class.
  
  Notes and Limitations:
  
  1. Any values which are not numpy arrays will be first converted to
    an array before serializing.
  2. Serializing strings or arrays of strings is complicated because numpy
    doesn't support variable length strings. By default, a python string
    converted to a numpy array will be converted to a fixed size dtype (of the
    form 'Un' where n is the size of the largest string). During serialization
    this information is lost and the deserialization produces an object array
    with bytes elements. These need to be manually converted back
    to a unicode string using `object.astype('U?') where ? is the length of the
    largest string in the array.
  
  #### Example
  ```python
    options_data = {
        'instrument_type': 'EuropeanOption',
        'strikes': np.array([1.0, 2.0, 3.0], dtype=np.float64),
        'is_call': np.array([True, True, False]),
        'expiries': np.array([0.4, 1.3, 2.3], dtype=np.float64)
    }
    barriers_data = {
        'instrument_type': 'BarrierOption',
        'strikes': np.array([1.0, 2.0, 3.0], dtype=np.float64),
        'is_call': np.array([True, True, False]),
        'expiries': np.array([0.4, 1.3, 2.3], dtype=np.float64),
        'barrier': np.array([1.4, 2.5, 2.5], dtype=np.float64),
        'is_knockout': np.array([True, True, False])
    }
    with ArrayDictWriter('datafile.bin') as writer:
      writer.write(options_data)
      writer.write(barriers_data)
  ```
class_docstr_tok: ["Writer","to","write","dictionaries","of","numpy","arrays","in","binary","format",".","Writes","dictionaries","with","string","keys","and","numpy","array","values","as","records","into","a","[","tfrecords","]","(","https",":","\/\/www.tensorflow.org\/tutorials\/load_data\/tfrecord",")","file",".","The","usage","of","tfrecords","should","be","treated","as","an","implementation","detail",".","To","read","the","file",",","use","the","`","ArrayDictReader","`","class",".","Notes","and","Limitations",":","1",".","Any","values","which","are","not","numpy","arrays","will","be","first","converted","to","an","array","before","serializing",".","2",".","Serializing","strings","or","arrays","of","strings","is","complicated","because","numpy","does","n't","support","variable","length","strings",".","By","default",",","a","python","string","converted","to","a","numpy","array","will","be","converted","to","a","fixed","size","dtype","(","of","the","form","'Un","'","where","n","is","the","size","of","the","largest","string",")",".","During","serialization","this","information","is","lost","and","the","deserialization","produces","an","object","array","with","bytes","elements",".","These","need","to","be","manually","converted","back","to","a","unicode","string","using","`","object.astype","(","'","U","?","'",")","where","?","is","the","length","of","the","largest","string","in","the","array",".","#","#","#","#","Example","``","`","python","options_data","=","{","'instrument_type","'",":","'EuropeanOption","'",",","'strikes","'",":","np.array","(","[","1.0",",","2.0",",","3.0","]",",","dtype=np.float64",")",",","'is_call","'",":","np.array","(","[","True",",","True",",","False","]",")",",","'expiries","'",":","np.array","(","[","0.4",",","1.3",",","2.3","]",",","dtype=np.float64",")","}","barriers_data","=","{","'instrument_type","'",":","'BarrierOption","'",",","'strikes","'",":","np.array","(","[","1.0",",","2.0",",","3.0","]",",","dtype=np.float64",")",",","'is_call","'",":","np.array","(","[","True",",","True",",","False","]",")",",","'expiries","'",":","np.array","(","[","0.4",",","1.3",",","2.3","]",",","dtype=np.float64",")",",","'barrier","'",":","np.array","(","[","1.4",",","2.5",",","2.5","]",",","dtype=np.float64",")",",","'is_knockout","'",":","np.array","(","[","True",",","True",",","False","]",")","}","with","ArrayDictWriter","(","'datafile.bin","'",")","as","writer",":","writer.write","(","options_data",")","writer.write","(","barriers_data",")","``","`"]
docstr: Exits a `with` block and closes the file.
docstr_tok: ["Exits","a","`","with","`","block","and","closes","the","file","."]
code: def __exit__(self, unused_type, unused_value, unused_traceback):
      """Exits a `with` block and closes the file."""
      del unused_type, unused_value, unused_traceback
      self.close()
  
file_path: tf-quant-finance/tf_quant_finance/experimental/io.py
imports: from typing import Dict, Callable, Optional
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 3 for calling the ArrayDictWriter obj's underlying member method code with example usage: obj.__exit__(unused_type, unused_value, unused_traceback) without return types