code: def _rd_dat_file(file_name, dir_name, pb_dir, fmt, start_byte, n_samp):
      
  
      # element_count is the number of elements to read using np.fromfile
      # for local files
      # byte_count is the number of bytes to read for streaming files
      if fmt == '212':
          byte_count = _required_byte_num('read', '212', n_samp)
          element_count = byte_count
      elif fmt in ['310', '311']:
          byte_count = _required_byte_num('read', fmt, n_samp)
          element_count = byte_count
      else:
          element_count = n_samp
          byte_count = n_samp * BYTES_PER_SAMPLE[fmt]
  
      # Local dat file
      if pb_dir is None:
          with open(os.path.join(dir_name, file_name), 'rb') as fp:
              fp.seek(start_byte)
              sig_data = np.fromfile(fp, dtype=np.dtype(DATA_LOAD_TYPES[fmt]),
                                     count=element_count)
      # Stream dat file from physiobank
      else:
          sig_data = download._stream_dat(file_name, pb_dir, byte_count,
                                          start_byte,
                                          np.dtype(DATA_LOAD_TYPES[fmt]))
  
      return sig_data
docs: Read data from a dat file, either local or remote, into a 1d numpy
      array.
  
      This is the lowest level dat reading function (along with
      `_stream_dat` which this function may call), and is called by
      `_rd_dat_signals`.
  
      Parameters
      ----------
      start_byte : int
          The starting byte number to read from.
      n_samp : int
          The total number of samples to read. Does NOT need to create
          whole blocks for special format. Any number of samples should be
          readable.
      * other params
          See docstring for `_rd_dat_signals`
  
      Returns
      -------
      sig_data : numpy array
          The data read from the dat file. The dtype varies depending on
          fmt. Byte aligned fmts are read in their final required format.
          Unaligned formats are read as uint8 to be further processed.
  
      Notes
      -----
      See docstring notes for `_rd_dat_signals`