class_docstr: A base class that returns constant values.
  
  Parameters
  ----------
  mode: immediate_value, file_value (Optional)
      * Determines how the constant value is stored in the internal MIL format.
      * For large constants such as convolution weights, use ``file_value``.
      * For smaller-size constants such as values of a stride, use ``immediate_value``.
  
  val: const<\*,T> (Required)
  
  Returns
  -------
  const<\*,T>
  
  Attributes
  ----------
  T: fp16, fp32, i32, str, bool
class_docstr_tok: ["A","base","class","that","returns","constant","values",".","Parameters","--","--","--","--","--","mode",":","immediate_value",",","file_value","(","Optional",")","*","Determines","how","the","constant","value","is","stored","in","the","internal","MIL","format",".","*","For","large","constants","such","as","convolution","weights",",","use","``","file_value","``",".","*","For","smaller-size","constants","such","as","values","of","a","stride",",","use","``","immediate_value","``",".","val",":","const","<","\\","*",",","T",">","(","Required",")","Returns","--","--","--","-","const","<","\\","*",",","T",">","Attributes","--","--","--","--","--","T",":","fp16",",","fp32",",","i32",",","str",",","bool"]
code: def _get_type_val(self, value):
      int32_max = np.int32(np.iinfo(np.int32).max)
      int32_min = np.int32(np.iinfo(np.int32).min)
  
      if isinstance(value, (float, np.float64)):
          value = np.float32(value)
      elif isinstance(value, bool):
          pass
      elif isinstance(value, (int, np.int64)):
          if value > int32_max:
              value = int32_max
          elif value < int32_min:
              value = int32_min
          else:
              value = np.int32(value)
      elif isinstance(value, (tuple, list, np.ndarray)):
          value = (
              np.array(value)
              if isinstance(value, (tuple, list))
              else value
          )
          if value.dtype in [np.uint64, np.int64]:
              logger.debug(
                  f"Downcast const op {self.name} data {builtin_to_string(numpy_type_to_builtin_type(value.dtype))} as int32"
              )
              value_clip_max = np.where(
                  value > int32_max, int32_max, np.int32(value)
              )
              value_clip_min = np.where(
                  value_clip_max < int32_min,
                  int32_min,
                  np.int32(value_clip_max),
              )
              value = value_clip_min
          if value.dtype == np.float64:
              logger.debug(
                  f"Downcast const op {self.name} data fp64 as fp32"
              )
              value = value.astype(np.float32)
      elif isinstance(value, mil_list):
          # If val that was passed in is of type mil_list, which is just a wrapper on top of
          # python list, then construct the list type.
          list_value = value.ls
          if len(list_value) == 0:
              raise ValueError("'mil_list' points to an empty list")
          builtin_elem_type, _ = self._get_type_val(list_value[0])
          # mil_list is a special case that we want to preserve the int64 element type
          if isinstance(list_value[0], np.int64):
              builtin_elem_type = types.int64
          builtin_type = types_list(
              builtin_elem_type,
              init_length=len(list_value),
              dynamic_length=False,
          )
          return builtin_type, value
  
      if not isinstance(
          value, (np.generic, np.ndarray, str, bool, mil_list)
      ):
          raise ValueError(f"Unknown value for constant: {value}")
  
      _, builtin_type = numpy_val_to_builtin_val(value)
      return builtin_type, value
  
imports: import copy
  import numpy
  from coremltools import _logger
  from coremltools.converters.mil.mil import Block, get_existing_symbol, get_new_symbol, types
  from coremltools.converters.mil.mil.input_type import DefaultInputs, InputSpec, InternalInputType, ListInputType, PyFunctionInputType, TensorInputType, TupleInputType
  from coremltools.converters.mil.mil.operation import NONE, SYMBOL, VALUE, Operation, mil_list, precondition
  from coremltools.converters.mil.mil.ops.defs._op_reqs import register_op
  from coremltools.converters.mil.mil.ops.defs._utils import infer_type_with_broadcast, promoted_primitive_type
  from coremltools.converters.mil.mil.types import is_compatible_type
  from coremltools.converters.mil.mil.types.type_list import list
  from coremltools.converters.mil.mil.types.type_mapping import builtin_to_string, is_subtype, numpy_type_to_builtin_type, numpy_val_to_builtin_val
label_desc: Use image node_id 3 for calling the Const obj's underlying member method code with example usage: obj._get_type_val(value) and returns: builtin_type,  value, builtin_type,  value