parameters: (self, ms_dict, cast_key, key, val)
docstring: put data in ms_dict when field type is string
docstring_summary: put data in ms_dict when field type is string
docstring_tokens: put data in ms_dict when field type is string
function: def _get_data_when_scalar_field(self, ms_dict, cast_key, key, val):
          """put data in ms_dict when field type is string"""
          if isinstance(val.numpy(), (np.ndarray, list)):
              raise ValueError("The response key: {}, value: {} from TFRecord should be a scalar.".format(key, val))
          if self.feature_dict[key].dtype == self.tf.string:
              if cast_key in self.bytes_fields_list:
                  ms_dict[cast_key] = val.numpy()
              else:
                  ms_dict[cast_key] = str(val.numpy(), encoding="utf-8")
          elif self._cast_type(self.feature_dict[key].dtype).startswith("int"):
              ms_dict[cast_key] = int(val.numpy())
          else:
              ms_dict[cast_key] = float(val.numpy())
function_tokens: def _get_data_when_scalar_field ( self , ms_dict , cast_key , key , val ) : if isinstance ( val . numpy ( ) , ( np . ndarray , list ) ) : raise ValueError ( "The response key: {}, value: {} from TFRecord should be a scalar." . format ( key , val ) ) if self . feature_dict [ key ] . dtype == self . tf . string : if cast_key in self . bytes_fields_list : ms_dict [ cast_key ] = val . numpy ( ) else : ms_dict [ cast_key ] = str ( val . numpy ( ) , encoding = "utf-8" ) elif self . _cast_type ( self . feature_dict [ key ] . dtype ) . startswith ( "int" ) : ms_dict [ cast_key ] = int ( val . numpy ( ) ) else : ms_dict [ cast_key ] = float ( val . numpy ( ) )