docstr: Intializes TF variables required for CF generation.
docstr_tok: ["Intializes","TF","variables","required","for","CF","generation","."]
code: def do_cf_initializations(
      self, total_CFs, algorithm, features_to_vary
  ):
      """Intializes TF variables required for CF generation."""
  
      self.cf_init_weights = [total_CFs, algorithm, features_to_vary]
  
      if algorithm == "RandomInitCF":
          # no. of times to run the experiment with random inits for diversity
          self.total_random_inits = total_CFs
          self.total_CFs = 1  # size of counterfactual set
      else:
          self.total_random_inits = 0
          self.total_CFs = total_CFs  # size of counterfactual set
  
      # a placeholder for original instance
      self.x1 = tf.placeholder(
          tf.float32, shape=(1, self.minx.shape[1])
      )
  
      # target CF placeholder
      self.target_cf = tf.placeholder(tf.float32, (1, 1))
  
      # learning rate for GD
      self.learning_rate = tf.placeholder(tf.float32, ())
  
      # CF initializations
      self.cfs = []
      self.cf_init = tf.placeholder(
          tf.float32, shape=(1, self.minx.shape[1])
      )
      self.cf_assign = []
      for i in range(self.total_CFs):
          self.cfs.append(tf.Variable(self.minx, dtype=tf.float32))
          self.cf_assign.append(tf.assign(self.cfs[i], self.cf_init))
  
      # freezing those columns that need to be fixed
      self.feat_to_vary_idxs = (
          self.data_interface.get_indexes_of_features_to_vary(
              features_to_vary=features_to_vary
          )
      )
  
      frozen_dims = np.array(
          [
              [
                  1.0 if ix in self.feat_to_vary_idxs else 0.0
                  for ix in range(self.minx.shape[1])
              ]
          ]
      )
      self.cfs_frozen = []
      for i in range(self.total_CFs):
          frozen = tf.multiply(
              self.cfs[i], tf.constant(frozen_dims, dtype=tf.float32)
          )
          self.cfs_frozen.append(
              frozen + tf.stop_gradient(-frozen + self.cfs[i])
          )
  
      # Future Support: a dictionary of options for optimizers, only checked with tensorflow optimizers:
      # need to check with others
      self.optimizers_options = {
          "tensorflow": self.tensorflow_optimizers,
          "scipy": self.scipy_optimizers,
      }
  
imports: import collections
  import copy
  import random
  import timeit
  import numpy
  import tensorflow
  from dice_ml import diverse_counterfactuals
  from dice_ml.counterfactual_explanations import CounterfactualExplanations
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
label_desc: Use image node_id 3 for calling the DiceTensorFlow1 obj's underlying member method code with example usage: obj.do_cf_initializations(total_CFs, algorithm, features_to_vary) without return types