class_docstr: Linear chain conditional random field (CRF).
  
  Inherits from: `tf.keras.layers.Layer`.
  
  References:
      - [Conditional Random Field](https://en.wikipedia.org/wiki/Conditional_random_field)
  
  Example:
  
  >>> layer = tfa.layers.CRF(4)
  >>> inputs = np.random.rand(2, 4, 8).astype(np.float32)
  >>> decoded_sequence, potentials, sequence_length, chain_kernel = layer(inputs)
  >>> decoded_sequence.shape
  TensorShape([2, 4])
  >>> potentials.shape
  TensorShape([2, 4, 4])
  >>> sequence_length
  <tf.Tensor: shape=(2,), dtype=int64, numpy=array([4, 4])>
  >>> chain_kernel.shape
  TensorShape([4, 4])
  
  Args:
      units: Positive integer, dimensionality of the reservoir.
      chain_initializer: Orthogonal matrix. Default to `orthogonal`.
      use_boundary: `Boolean`, whether the layer uses a boundary vector. Default to `True`.
      boundary_initializer: Tensors initialized to 0. Default to `zeros`.
      use_kernel: `Boolean`, whether the layer uses a kernel weights. Default to `True`.
  Call Args:
      inputs: Positive integer, dimensionality of the output space.
      mask: A boolean `Tensor` of shape `[batch_size, sequence_length]`
          or `None`. Default to `None`.
  Raises:
      ValueError: If input mask doesn't have dim 2 or None.
      NotImplementedError: If left padding is provided.
class_docstr_tok: ["Linear","chain","conditional","random","field","(","CRF",")",".","Inherits","from",":","`","tf.keras.layers.Layer","`",".","References",":","-","[","Conditional","Random","Field","]","(","https",":","\/\/en.wikipedia.org\/wiki\/Conditional_random_field",")","Example",":",">",">",">","layer","=","tfa.layers.CRF","(","4",")",">",">",">","inputs","=","np.random.rand","(","2",",","4",",","8",")",".astype","(","np.float32",")",">",">",">","decoded_sequence",",","potentials",",","sequence_length",",","chain_kernel","=","layer","(","inputs",")",">",">",">","decoded_sequence.shape","TensorShape","(","[","2",",","4","]",")",">",">",">","potentials.shape","TensorShape","(","[","2",",","4",",","4","]",")",">",">",">","sequence_length","<","tf.Tensor",":","shape=","(","2",",",")",",","dtype=int64",",","numpy=array","(","[","4",",","4","]",")",">",">",">",">","chain_kernel.shape","TensorShape","(","[","4",",","4","]",")","Args",":","units",":","Positive","integer",",","dimensionality","of","the","reservoir",".","chain_initializer",":","Orthogonal","matrix",".","Default","to","`","orthogonal","`",".","use_boundary",":","`","Boolean","`",",","whether","the","layer","uses","a","boundary","vector",".","Default","to","`","True","`",".","boundary_initializer",":","Tensors","initialized","to","0",".","Default","to","`","zeros","`",".","use_kernel",":","`","Boolean","`",",","whether","the","layer","uses","a","kernel","weights",".","Default","to","`","True","`",".","Call","Args",":","inputs",":","Positive","integer",",","dimensionality","of","the","output","space",".","mask",":","A","boolean","`","Tensor","`","of","shape","`","[","batch_size",",","sequence_length","]","`","or","`","None","`",".","Default","to","`","None","`",".","Raises",":","ValueError",":","If","input","mask","does","n't","have","dim","2","or","None",".","NotImplementedError",":","If","left","padding","is","provided","."]
docstr: Currently underline CRF fucntion (provided by
  tensorflow_addons.text.crf) do not support bi-direction masking (left
  padding / right padding), it support right padding by tell it the
  sequence length.
  
  this function is compute the sequence length from input and
  mask.
docstr_tok: ["Currently","underline","CRF","fucntion","(","provided","by","tensorflow_addons.text.crf",")","do","not","support","bi-direction","masking","(","left","padding","\/","right","padding",")",",","it","support","right","padding","by","tell","it","the","sequence","length",".","this","function","is","compute","the","sequence","length","from","input","and","mask","."]
code: def _get_sequence_length(self, input_, mask):
      """Currently underline CRF fucntion (provided by
      tensorflow_addons.text.crf) do not support bi-direction masking (left
      padding / right padding), it support right padding by tell it the
      sequence length.
  
      this function is compute the sequence length from input and
      mask.
      """
      if mask is not None:
          sequence_length = self.mask_to_sequence_length(mask)
      else:
          # make a mask tensor from input, then used to generate sequence_length
          input_energy_shape = tf.shape(input_)
          raw_input_shape = tf.slice(input_energy_shape, [0], [2])
          alt_mask = tf.ones(raw_input_shape)
  
          sequence_length = self.mask_to_sequence_length(alt_mask)
  
      return sequence_length
  
file_path: addons/tensorflow_addons/layers/crf.py
imports: import tensorflow
  from typeguard import typechecked
  from tensorflow_addons.text.crf import crf_decode
  from tensorflow_addons.utils import types
label_desc: Use image node_id 3 for calling the CRF obj's underlying member method code with example usage: obj._get_sequence_length(input_, mask) and returns: sequence_length