code: def _return_samples(samples, state_names_map=None):
      """
      A utility function to return samples according to type
      """
      df = pd.DataFrame.from_records(samples)
      if state_names_map is not None:
          for var in df.columns:
              if var != "_weight":
                  df[var] = df[var].map(state_names_map[var])
      return df
  
imports: import itertools
  import math
  import os
  import networkx
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from pgmpy.inference import Inference
  from pgmpy.utils import _check_1d_array_object, _check_length_equal, compat_fns
label_desc: Use image node_id 1 for calling a global function with example usage: _return_samples(samples, state_names_map) and returns: df