code: def _input_type(param, dim, dtype, name):
      """Checks if the input parameter is a callable or piecewise constant."""
      # If the parameter is callable but not a piecewise constant use
      # generic sampling method (e.g., Euler).
      sample_with_generic = False
      is_piecewise_constant = True
      if hasattr(param, "is_piecewise_constant"):
          if param.is_piecewise_constant:
              jump_locations = param.jump_locations()
              jumps_shape = jump_locations.shape
              if jumps_shape.rank > 2:
                  raise ValueError(
                      "Batch rank of `jump_locations` should be `1` for all piecewise "
                      "constant arguments but {} instead".format(
                          len(jumps_shape[:-1])
                      )
                  )
              if jumps_shape.rank == 2:
                  if dim != jumps_shape[0]:
                      raise ValueError(
                          "Batch shape of `jump_locations` should be either empty or "
                          "`[{0}]` but `[{1}]` instead".format(
                              dim, jumps_shape[0]
                          )
                      )
              if name == "mean_reversion" and jumps_shape[0] > 0:
                  # Exact discretization currently not supported with time-dependent mr
                  sample_with_generic = True
              return param, sample_with_generic, is_piecewise_constant
          else:
              is_piecewise_constant = False
              sample_with_generic = True
      elif callable(param):
          is_piecewise_constant = False
          sample_with_generic = True
      else:
          # Otherwise, input is a `Tensor`, return a `PiecewiseConstantFunc`.
          param = tf.convert_to_tensor(param, dtype=dtype, name=name)
          param_shape = param.shape.as_list()
          param_rank = param.shape.rank
          # If `param` is not a scalar, check that it is of correct shape
          if param_shape:
              if param_shape[-1] != dim:
                  # This is an error, we need as many parameters as the number of `dim`
                  raise ValueError(
                      "Length of {} ({}) should be the same as `dims`({}).".format(
                          name, param_shape[0], dim
                      )
                  )
          else:
              # Broadcast scalar to shape [1]
              param = param[tf.newaxis]
          if param_rank == 2:
              # This is when the parameter is a correlation matrix
              jump_locations = []
              values = tf.expand_dims(param, axis=0)
          else:
              jump_locations = [] if dim == 1 else [[]] * dim
              values = (
                  param if dim == 1 else tf.expand_dims(param, axis=-1)
              )
          param = piecewise.PiecewiseConstantFunc(
              jump_locations=jump_locations, values=values, dtype=dtype
          )
  
      return param, sample_with_generic, is_piecewise_constant
  
imports: from typing import Callable, Union, Tuple, Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import gradient
  from tf_quant_finance.math import piecewise
  from tf_quant_finance.math import random
  from tf_quant_finance.models import euler_sampling
  from tf_quant_finance.models import generic_ito_process
  from tf_quant_finance.models import utils
label_desc: Use image node_id 3 for calling a global function with example usage: _input_type(param, dim, dtype, name) and returns: param,  sample_with_generic,  is_piecewise_constant, param,  sample_with_generic,  is_piecewise_constant