class_docstr: File writer for TFRecord dataset.
  
  TFRecordWriter serializes tensors in tf.Example schema and write them
  into files in TFRecord format. The written file can be loaded with
  tf.data.TFRecordDataset.
class_docstr_tok: ["File","writer","for","TFRecord","dataset",".","TFRecordWriter","serializes","tensors","in","tf.Example","schema","and","write","them","into","files","in","TFRecord","format",".","The","written","file","can","be","loaded","with","tf.data.TFRecordDataset","."]
docstr: Wrap value np.array into tf.train.Feature and add it into features.
docstr_tok: ["Wrap","value","np.array","into","tf.train.Feature","and","add","it","into","features","."]
code: def _add_dense_tensor_to_features(self, name, value, dtype, features):
      """Wrap value np.array into tf.train.Feature and add it into features."""
      if np.isscalar(value):
          value = [value]  # Convert scalar into a list.
      else:
          value = value.flatten()
  
      example_dtype = self._map_tensor_dtype_to_example_dtype(dtype)
      if example_dtype is tf.int64:
          features[name] = tf.train.Feature(
              int64_list=tf.train.Int64List(value=value)
          )
      elif example_dtype is tf.float32:
          features[name] = tf.train.Feature(
              float_list=tf.train.FloatList(value=value)
          )
      elif example_dtype is tf.string:
          features[name] = tf.train.Feature(
              bytes_list=tf.train.BytesList(value=value)
          )
      else:
          raise TypeError(
              f"Dtype {dtype} is not supported in tf.Example."
          )
  
file_path: io/tests/test_atds_avro/utils/tf_record_writer.py
imports: import os
  from tests.test_atds_avro.utils.generator.tensor_generator import TensorGeneratorBase
  from tests.test_atds_avro.utils.generator.sparse_tensor_generator import SparseTensorGeneratorBase
  from tests.test_atds_avro.utils.generator.varlen_tensor_generator import VarLenTensorGeneratorBase
  import numpy
  import tensorflow
  from tests.test_atds_avro.utils.file_writer import FileWriter
label_desc: Use image node_id 5 for calling the TFRecordWriter obj's underlying member method code with example usage: obj._add_dense_tensor_to_features(name, value, dtype, features) without return types