def METHOD_NAME(self, shape):
    if isinstance(shape, tf.Tensor):
        if shape.dtype == tf.int32:
            shape = tf.cast(shape, tf.int64)
    elif isinstance(shape, list):
        shape_dims = []
        for dim_value in shape:
            if isinstance(dim_value, int):
                shape_dims.append(tf.constant(dim_value, tf.int64))
            elif isinstance(dim_value, tf.Tensor) and dim_value.shape.rank == 0:
                if dim_value.dtype == tf.int32:
                    dim_value = tf.cast(dim_value, tf.int64)
                shape_dims.append(dim_value)
            else:
                raise TypeError("Input shape dimension is neither scalar tensor nor int")
        shape = tf.stack(shape_dims)
    else:
        raise TypeError("Input shape is neither tensor nor list")
    return shape