class_docstr: This class enables to use different (independent) functions respective
  to the data 'label'.
  We assume the 'label' is stored in the extra column of X.
class_docstr_tok: ["This","class","enables","to","use","different","(","independent",")","functions","respective","to","the","data","'label","'",".","We","assume","the","'label","'","is","stored","in","the","extra","column","of","X","."]
code: def __call__(self, X: TensorType) -> tf.Tensor:
      ind = tf.gather(
          tf.transpose(X), tf.shape(X)[1] - 1
      )  # ind = X[:,-1]
      ind = tf.cast(ind, tf.int32)
      X = tf.transpose(
          tf.gather(tf.transpose(X), tf.range(0, tf.shape(X)[1] - 1))
      )  # X = X[:,:-1]
  
      # split up X into chunks corresponding to the relevant likelihoods
      x_list = tf.dynamic_partition(X, ind, len(self.functions))
      # apply the likelihood-function to each section of the data
      results = [m(x) for x, m in zip(x_list, self.functions)]
      # stitch the results back together
      partitions = tf.dynamic_partition(
          tf.range(0, tf.size(ind)), ind, len(self.functions)
      )
      return tf.dynamic_stitch(partitions, results)
  
imports: from typing import Collection, Optional, Sequence, Tuple
  import numpy
  import tensorflow
  from check_shapes import check_shape
  from check_shapes import check_shapes, inherit_check_shapes
  from .base import Module, Parameter, TensorType
  from .config import default_float, default_int
label_desc: Use image node_id 2 for calling the SwitchedFunction obj's underlying member method code with example usage: obj.__call__(X) and returns: tf