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 tensor-to-tensor op.
  
  This method is used for implementing ops that take a tensor and return a new
  tensor, such as tf.expand_dims or tf.transpose. Implementing wrappers
  should apply `op_fn` to the backing tensor(s) and return an new wrapper
  instance with the updated backing tensor.
  
  Args:
     op_fn: Callable that applies tensor-to-tensor op to the given Tensor.
      E.g. applies tf.expand_dims.
  
  Returns:
    A TensorWrapper instance with updated backing tensor(s).
docstr_tok: ["Applies","given","tensor-to-tensor","op",".","This","method","is","used","for","implementing","ops","that","take","a","tensor","and","return","a","new","tensor",",","such","as","tf.expand_dims","or","tf.transpose",".","Implementing","wrappers","should","apply","`","op_fn","`","to","the","backing","tensor","(","s",")","and","return","an","new","wrapper","instance","with","the","updated","backing","tensor",".","Args",":","op_fn",":","Callable","that","applies","tensor-to-tensor","op","to","the","given","Tensor",".","E.g",".","applies","tf.expand_dims",".","Returns",":","A","TensorWrapper","instance","with","updated","backing","tensor","(","s",")","."]
code: def _apply_op(self, op_fn):
      """Applies given tensor-to-tensor op.
  
      This method is used for implementing ops that take a tensor and return a new
      tensor, such as tf.expand_dims or tf.transpose. Implementing wrappers
      should apply `op_fn` to the backing tensor(s) and return an new wrapper
      instance with the updated backing tensor.
  
      Args:
         op_fn: Callable that applies tensor-to-tensor op to the given Tensor.
          E.g. applies tf.expand_dims.
  
      Returns:
        A TensorWrapper instance with updated 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 15 for calling the TensorWrapper obj's underlying member method code with example usage: obj._apply_op(op_fn) without return types