class_docstr: Base class for Tensor wrappers.
  
  Implements ops that manipulate the backing tensors of Tensor wrappers
  (e.g. DateTensor, PeriodTensor). These ops are mostly about reshaping the
  backing tensors, such as tf.reshape, tf.expand_dims, tf.stack, etc. Also
  includes indexing and slicing.
  
  Inheritors must implement _apply_op(self, op_fn) and provide a static method
  _apply_sequence_to_tensor_op(op_fn, tensors). For example:
  
  ```python
  class MyWrapper(TensorWrapper):
    def __init__(self, backing_tensor):
       self._backing_tensor = backing_tensor
  
    def _apply_op(self, op_fn):
      new_backing_tensor = op_fn(self._backing_tensor)
      return MyWrapper(new_backing_tensor)
  
    @staticmethod
    def _apply_sequence_to_tensor_op(op_fn, tensors):
      new_backing_tensor = op_fn([t._backing_tensor for t in tensors])
      return MyWrapper(new_backing_tensor)
  ```
  
  Then 'MyWrapper` can be used as follows:
  
  ```python
  m1 = MyWrapper(tf.constant([[1, 2, 3], [4, 5, 6]]))
  m2 = MyWrapper(...)
  m3 = m1[0, 1:-1]
  m4 = m1.expand_dims(axis=-1)
  m5 = MyWrapper.concat((m1, m2), axis=-1)
  # etc.
  ```
class_docstr_tok: ["Base","class","for","Tensor","wrappers",".","Implements","ops","that","manipulate","the","backing","tensors","of","Tensor","wrappers","(","e.g",".","DateTensor",",","PeriodTensor",")",".","These","ops","are","mostly","about","reshaping","the","backing","tensors",",","such","as","tf.reshape",",","tf.expand_dims",",","tf.stack",",","etc",".","Also","includes","indexing","and","slicing",".","Inheritors","must","implement","_apply_op","(","self",",","op_fn",")","and","provide","a","static","method","_apply_sequence_to_tensor_op","(","op_fn",",","tensors",")",".","For","example",":","``","`","python","class","MyWrapper","(","TensorWrapper",")",":","def","__init__","(","self",",","backing_tensor",")",":","self._backing_tensor","=","backing_tensor","def","_apply_op","(","self",",","op_fn",")",":","new_backing_tensor","=","op_fn","(","self._backing_tensor",")","return","MyWrapper","(","new_backing_tensor",")","@","staticmethod","def","_apply_sequence_to_tensor_op","(","op_fn",",","tensors",")",":","new_backing_tensor","=","op_fn","(","[","t._backing_tensor","for","t","in","tensors","]",")","return","MyWrapper","(","new_backing_tensor",")","``","`","Then","'MyWrapper","`","can","be","used","as","follows",":","``","`","python","m1","=","MyWrapper","(","tf.constant","(","[","[","1",",","2",",","3","]",",","[","4",",","5",",","6","]","]",")",")","m2","=","MyWrapper","(","...",")","m3","=","m1","[","0",",","1",":","-1","]","m4","=","m1.expand_dims","(","axis=-1",")","m5","=","MyWrapper.concat","(","(","m1",",","m2",")",",","axis=-1",")","#","etc",".","``","`"]
docstr: Applies given sequence-to-tensor op.
  
  This method is used for implementing ops that take a sequence of tensors and
  return a new tensor, such as tf.concat and tf.stack. Implementing wrappers
  should apply `op_fn` to the backing tensor(s) and return an new wrapper
  instance with the combined backing tensor.
  
  Args:
   op_fn: Callable that applies sequence-to-tensor op to the given sequence
     of Tensors. E.g. applies tf.concat.
   tensor_wrappers: a sequence of tensor wrappers to be transformed. All
     elements have the type of the implementing TensorWrapper class.
  
  Returns:
    A TensorWrapper instance with combined backing tensor(s).
docstr_tok: ["Applies","given","sequence-to-tensor","op",".","This","method","is","used","for","implementing","ops","that","take","a","sequence","of","tensors","and","return","a","new","tensor",",","such","as","tf.concat","and","tf.stack",".","Implementing","wrappers","should","apply","`","op_fn","`","to","the","backing","tensor","(","s",")","and","return","an","new","wrapper","instance","with","the","combined","backing","tensor",".","Args",":","op_fn",":","Callable","that","applies","sequence-to-tensor","op","to","the","given","sequence","of","Tensors",".","E.g",".","applies","tf.concat",".","tensor_wrappers",":","a","sequence","of","tensor","wrappers","to","be","transformed",".","All","elements","have","the","type","of","the","implementing","TensorWrapper","class",".","Returns",":","A","TensorWrapper","instance","with","combined","backing","tensor","(","s",")","."]
code: def _apply_sequence_to_tensor_op(cls, op_fn, tensor_wrappers):
      """Applies given sequence-to-tensor op.
  
      This method is used for implementing ops that take a sequence of tensors and
      return a new tensor, such as tf.concat and tf.stack. Implementing wrappers
      should apply `op_fn` to the backing tensor(s) and return an new wrapper
      instance with the combined backing tensor.
  
      Args:
       op_fn: Callable that applies sequence-to-tensor op to the given sequence
         of Tensors. E.g. applies tf.concat.
       tensor_wrappers: a sequence of tensor wrappers to be transformed. All
         elements have the type of the implementing TensorWrapper class.
  
      Returns:
        A TensorWrapper instance with combined backing tensor(s).
      """
      raise NotImplementedError()
  
file_path: tf-quant-finance/tf_quant_finance/datetime/tensor_wrapper.py
imports: import abc
  import tensorflow.compat.v2
label_desc: Use image node_id 14 for calling the TensorWrapper obj's underlying member method code with example usage: obj._apply_sequence_to_tensor_op(cls, op_fn, tensor_wrappers) without return types