code: def _initialize_centroids(
      X, k, algorithm="first-k", random_state=None
  ):
      if isinstance(k, torch.Tensor):
          k = k.item()
  
      if not isinstance(random_state, numpy.random.mtrand.RandomState):
          random_state = numpy.random.RandomState(random_state)
  
      if algorithm == "first-k":
          return _cast_as_tensor(
              torch.clone(X[:k]), dtype=torch.float32
          )
  
      elif algorithm == "random":
          idxs = random_state.choice(len(X), size=k, replace=False)
          return _cast_as_tensor(
              torch.clone(X[idxs]), dtype=torch.float32
          )
  
      elif algorithm == "submodular-facility-location":
          selector = FacilityLocationSelection(
              k, random_state=random_state
          )
          return _cast_as_tensor(
              selector.fit_transform(X), dtype=torch.float32
          )
  
      elif algorithm == "submodular-feature-based":
          selector = FeatureBasedSelection(k, random_state=random_state)
          return selector.fit_transform(X)
  
file_path: pomegranate/pomegranate/_utils.py
imports: import numpy
  import torch
  import collections
  from apricot import FacilityLocationSelection
  from apricot import FeatureBasedSelection
label_desc: Use image node_id 8 for calling a global function with example usage: _initialize_centroids(X, k, algorithm, random_state) and returns: _cast_as_tensor, _cast_as_tensor, _cast_as_tensor, selector