code: def detect_lang(texts, sample_size=32):
      """
      ```
      detect language
      ```
      """
  
      # convert sentence pairs
      if (
          isinstance(texts, (tuple, list, np.ndarray))
          and len(texts) == 2
      ):
          texts = [texts[0], texts[1]]
      elif (
          isinstance(texts, (tuple, list, np.ndarray))
          and isinstance(texts[0], (tuple, list, np.ndarray))
          and len(texts[0]) == 2
      ):
          texts = [t[0] for t in texts]
  
      if isinstance(texts, (pd.Series, pd.DataFrame)):
          texts = texts.values
      if isinstance(texts, str):
          texts = [texts]
      if not isinstance(texts, (list, np.ndarray)):
          raise ValueError(
              "texts must be a list or NumPy array of strings"
          )
      lst = []
      for doc in texts[:sample_size]:
          try:
              lst.append(langdetect.detect(doc))
          except:
              continue
      if len(lst) == 0:
          warnings.warn(
              "Defaulting to English for language detection: could not detect language from documents. "
              + "This may be due to empty or invalid texts being provided to detect_lang."
          )
          lang = "en"
      else:
          lang = max(set(lst), key=lst.count)
      # return max(set(lst), key=lst.count)
      return lang
  
imports: from subprocess import DEVNULL, PIPE, Popen
  from ..imports import *
label_desc: Use image node_id 13 for calling a global function with example usage: detect_lang(texts, sample_size) and returns: lang